本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/api/organizations/fakes.FakeOrganizationRepository.FindByNameArgsForCall方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeOrganizationRepository.FindByNameArgsForCall方法的具體用法?Golang FakeOrganizationRepository.FindByNameArgsForCall怎麽用?Golang FakeOrganizationRepository.FindByNameArgsForCall使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/cli/cf/api/organizations/fakes.FakeOrganizationRepository
的用法示例。
在下文中一共展示了FakeOrganizationRepository.FindByNameArgsForCall方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
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.FindByNameInOrgError = errors.NewModelNotFoundError("Space", "space-name")
示例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)
})
It("it updates the organization in the config", func() {
callTarget([]string{"-o", "my-organization"})
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.FindByNameArgsForCall(0)).To(Equal("my-space"))
示例3:
[]string{"Select an org"},
[]string{"1. some-org"},
[]string{"2. my-new-org"},
[]string{"Select a space"},
[]string{"1. my-space"},
[]string{"2. some-space"},
))
Expect(Config.OrganizationFields().Guid).To(Equal("my-new-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("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"},