當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakeOrgRepository.FindByNameOrganization方法代碼示例

本文整理匯總了Golang中testhelpers/api.FakeOrgRepository.FindByNameOrganization方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeOrgRepository.FindByNameOrganization方法的具體用法?Golang FakeOrgRepository.FindByNameOrganization怎麽用?Golang FakeOrgRepository.FindByNameOrganization使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在testhelpers/api.FakeOrgRepository的用法示例。


在下文中一共展示了FakeOrgRepository.FindByNameOrganization方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

		It("passes requirements when targeting a space or org", func() {
			callTarget([]string{"-s", "i-love-space"}, reqFactory, config, orgRepo, spaceRepo)
			Expect(testcmd.CommandDidPassRequirements).To(BeTrue())

			callTarget([]string{"-o", "orgs-are-delightful"}, reqFactory, config, orgRepo, spaceRepo)
			Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
		})

		It("TestTargetOrganizationWhenUserHasAccess", func() {
			org := models.Organization{}
			org.Name = "my-organization"
			org.Guid = "my-organization-guid"

			orgRepo.Organizations = []models.Organization{org}
			orgRepo.FindByNameOrganization = org

			ui := callTarget([]string{"-o", "my-organization"}, reqFactory, config, orgRepo, spaceRepo)

			Expect(orgRepo.FindByNameName).To(Equal("my-organization"))
			Expect(ui.ShowConfigurationCalled).To(BeTrue())

			Expect(config.OrganizationFields().Guid).To(Equal("my-organization-guid"))
		})

		It("TestTargetOrganizationWhenUserDoesNotHaveAccess", func() {
			orgs := []models.Organization{}
			orgRepo.Organizations = orgs
			orgRepo.FindByNameErr = true

			ui := callTarget([]string{"-o", "my-organization"}, reqFactory, config, orgRepo, spaceRepo)
開發者ID:jibin-tomy,項目名稱:cli,代碼行數:30,代碼來源:target_test.go

示例2:

				"password": "password",
			}))

			Expect(orgRepo.FindByNameName).To(Equal("my-org"))
			Expect(spaceRepo.FindByNameName).To(Equal("my-space"))

			Expect(ui.ShowConfigurationCalled).To(BeTrue())
		})

		It("doesn't ask the user to select an org if they have one in their config", func() {
			Config.SetOrganizationFields(org2.OrganizationFields)

			Flags = []string{"-s", "my-space"}
			ui.Inputs = []string{"http://api.example.com", "[email protected]", "password"}

			orgRepo.FindByNameOrganization = models.Organization{}

			l := NewLogin(ui, Config, authRepo, endpointRepo, orgRepo, spaceRepo)
			testcmd.RunCommand(l, testcmd.NewContext("login", Flags), nil)

			Expect(Config.ApiEndpoint()).To(Equal("http://api.example.com"))
			Expect(Config.OrganizationFields().Guid).To(Equal("my-org-guid"))
			Expect(Config.SpaceFields().Guid).To(Equal("my-space-guid"))
			Expect(Config.AccessToken()).To(Equal("my_access_token"))
			Expect(Config.RefreshToken()).To(Equal("my_refresh_token"))

			Expect(endpointRepo.UpdateEndpointReceived).To(Equal("http://api.example.com"))
			Expect(authRepo.AuthenticateArgs.Credentials).To(Equal(map[string]string{
				"username": "[email protected]",
				"password": "password",
			}))
開發者ID:nimbus-cloud,項目名稱:cli,代碼行數:31,代碼來源:login_test.go


注:本文中的testhelpers/api.FakeOrgRepository.FindByNameOrganization方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。