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


Golang FakeOrganizationRepository.FindByNameArgsForCall方法代碼示例

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


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

示例1:

	BeforeEach(func() {
		orgRepo = new(organizationsfakes.FakeOrganizationRepository)
	})

	Context("when an org with the given name exists", func() {
		It("succeeds", func() {
			org := models.Organization{}
			org.Name = "my-org-name"
			org.GUID = "my-org-guid"
			orgReq := NewOrganizationRequirement("my-org-name", orgRepo)

			orgRepo.ListOrgsReturns([]models.Organization{org}, nil)
			orgRepo.FindByNameReturns(org, nil)

			err := orgReq.Execute()
			Expect(err).NotTo(HaveOccurred())
			Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-org-name"))
			Expect(orgReq.GetOrganization()).To(Equal(org))
		})
	})

	It("fails when the org with the given name does not exist", func() {
		orgError := errors.New("not found")
		orgRepo.FindByNameReturns(models.Organization{}, orgError)

		err := NewOrganizationRequirement("foo", orgRepo).Execute()
		Expect(err).To(HaveOccurred())
		Expect(err).To(Equal(orgError))
	})
})
開發者ID:Reejoshi,項目名稱:cli,代碼行數:30,代碼來源:organization_test.go

示例2:

				Expect(Config.RefreshToken()).To(Equal("my_refresh_token"))

				Expect(Config.APIEndpoint()).To(Equal("api.example.com"))
				Expect(Config.APIVersion()).To(Equal("some-version"))
				Expect(Config.AuthenticationEndpoint()).To(Equal("auth/endpoint"))
				Expect(Config.SSHOAuthClient()).To(Equal("some-client"))
				Expect(Config.MinCLIVersion()).To(Equal("1.0.0"))
				Expect(Config.MinRecommendedCLIVersion()).To(Equal("1.0.0"))
				Expect(Config.LoggregatorEndpoint()).To(Equal("loggregator/endpoint"))
				Expect(Config.DopplerEndpoint()).To(Equal("doppler/endpoint"))
				Expect(Config.RoutingAPIEndpoint()).To(Equal("routing/endpoint"))

				Expect(endpointRepo.GetCCInfoCallCount()).To(Equal(1))
				Expect(endpointRepo.GetCCInfoArgsForCall(0)).To(Equal("api.example.com"))

				Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-new-org"))
				Expect(spaceRepo.FindByNameArgsForCall(0)).To(Equal("my-space"))

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

			It("lets the user select an org and space by name", func() {
				ui.Inputs = []string{"api.example.com", "[email protected]", "password", "my-new-org", "my-space"}
				orgRepo.FindByNameReturns(org2, nil)

				testcmd.RunCLICommand("login", Flags, nil, updateCommandDependency, false)

				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Select an org"},
					[]string{"1. some-org"},
					[]string{"2. my-new-org"},
開發者ID:yingkitw,項目名稱:cli,代碼行數:31,代碼來源:login_test.go

示例3:

		BeforeEach(func() {
			org := models.Organization{
				OrganizationFields: models.OrganizationFields{
					Name: "other-org",
					GUID: "other-org-guid",
				}}
			orgRepo.FindByNameReturns(org, nil)

			spaceQuota := models.SpaceQuota{
				Name: "my-space-quota",
				GUID: "my-space-quota-guid",
			}
			spaceQuotaRepo.FindByNameAndOrgGUIDReturns(spaceQuota, nil)
		})

		It("assigns the space-quota from the specified org to the space", func() {
			runCommand("my-space", "-o", "other-org", "-q", "my-space-quota")

			Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("other-org"))
			spaceName, orgGUID := spaceQuotaRepo.FindByNameAndOrgGUIDArgsForCall(0)
			Expect(spaceName).To(Equal("my-space-quota"))
			Expect(orgGUID).To(Equal("other-org-guid"))

			actualSpaceName, actualOrgGUID, actualSpaceQuotaGUID := spaceRepo.CreateArgsForCall(0)
			Expect(actualSpaceName).To(Equal("my-space"))
			Expect(actualOrgGUID).To(Equal("other-org-guid"))
			Expect(actualSpaceQuotaGUID).To(Equal("my-space-quota-guid"))
		})
	})
})
開發者ID:Reejoshi,項目名稱:cli,代碼行數:30,代碼來源:create_space_test.go

示例4:

		Context("there are no errors", func() {
			BeforeEach(func() {
				org := models.Organization{}
				org.Name = "my-organization"
				org.GUID = "my-organization-guid"

				orgRepo.ListOrgsReturns([]models.Organization{org}, nil)
				orgRepo.FindByNameReturns(org, nil)
				config.SetOrganizationFields(models.OrganizationFields{Name: org.Name, GUID: org.GUID})
			})

			It("it updates the organization in the config", func() {
				callTarget([]string{"-o", "my-organization"})

				Expect(orgRepo.FindByNameCallCount()).To(Equal(1))
				Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-organization"))
				Expect(ui.ShowConfigurationCalled).To(BeTrue())

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

			It("updates the space in the config", func() {
				space := models.Space{}
				space.Name = "my-space"
				space.GUID = "my-space-guid"

				spaceRepo.FindByNameReturns(space, nil)

				callTarget([]string{"-s", "my-space"})

				Expect(spaceRepo.FindByNameCallCount()).To(Equal(1))
開發者ID:Reejoshi,項目名稱:cli,代碼行數:31,代碼來源:target_test.go

示例5:

				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"FAILED"},
					[]string{"security group", "my-nonexistent-security-group", "not found"},
				))
			})
		})

		Context("when the org does not exist", func() {
			BeforeEach(func() {
				fakeOrgRepo.FindByNameReturns(models.Organization{}, errors.New("Org org not found"))
			})

			It("fails and tells the user", func() {
				runCommand("sec group", "org", "space")

				Expect(fakeOrgRepo.FindByNameArgsForCall(0)).To(Equal("org"))
				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"FAILED"},
					[]string{"Org", "org", "not found"},
				))
			})
		})

		Context("when the space does not exist", func() {
			BeforeEach(func() {
				org := models.Organization{}
				org.Name = "org-name"
				org.GUID = "org-guid"
				fakeOrgRepo.ListOrgsReturns([]models.Organization{org}, nil)
				fakeOrgRepo.FindByNameReturns(org, nil)
				fakeSpaceRepo.FindByNameInOrgReturns(models.Space{}, errors.NewModelNotFoundError("Space", "space-name"))
開發者ID:yingkitw,項目名稱:cli,代碼行數:31,代碼來源:bind_security_group_test.go


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