本文整理汇总了Golang中code/cloudfoundry/org/cli/cf/api/organizations/organizationsfakes.FakeOrganizationRepository.FindByNameArgsForCall方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeOrganizationRepository.FindByNameArgsForCall方法的具体用法?Golang FakeOrganizationRepository.FindByNameArgsForCall怎么用?Golang FakeOrganizationRepository.FindByNameArgsForCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/cloudfoundry/org/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))
})
})
示例2:
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))
示例3:
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"))
示例4:
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"))
})
})
})
示例5:
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, ui)
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Select an org"},
[]string{"1. some-org"},
[]string{"2. my-new-org"},