本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/configuration/coreconfig.Repository.SetSpaceFields方法的典型用法代碼示例。如果您正苦於以下問題:Golang Repository.SetSpaceFields方法的具體用法?Golang Repository.SetSpaceFields怎麽用?Golang Repository.SetSpaceFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/cloudfoundry/org/cli/cf/configuration/coreconfig.Repository
的用法示例。
在下文中一共展示了Repository.SetSpaceFields方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
Expect(err.Error()).To(ContainSubstring("Incorrect Usage"))
Expect(err.Error()).To(ContainSubstring("No argument required"))
})
})
})
})
Context("when the user is logged in", func() {
BeforeEach(func() {
config = testconfig.NewRepositoryWithDefaults()
})
Context("when the user has a space targeted", func() {
BeforeEach(func() {
config.SetSpaceFields(models.SpaceFields{
GUID: "the-space-guid",
Name: "the-space-name",
})
serviceBuilder.GetServicesForSpaceWithPlansReturns(fakeServiceOfferings, nil)
})
It("lists all of the service offerings for the space", func() {
testcmd.RunCLICommand("marketplace", []string{}, requirementsFactory, updateCommandDependency, false, ui)
args := serviceBuilder.GetServicesForSpaceWithPlansArgsForCall(0)
Expect(args).To(Equal("the-space-guid"))
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Getting services from marketplace in org", "my-org", "the-space-name", "my-user"},
[]string{"OK"},
[]string{"service", "plans", "description"},
[]string{"aaa-my-service-offering", "service offering 2 description", "service-plan-c,", "service-plan-d"},
示例2:
callTarget([]string{"-o", "my-organization", "-s", "my-space"})
Expect(orgRepo.FindByNameCallCount()).To(Equal(1))
Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-organization"))
Expect(config.OrganizationFields().GUID).To(Equal("my-organization-guid"))
Expect(spaceRepo.FindByNameCallCount()).To(Equal(1))
Expect(spaceRepo.FindByNameArgsForCall(0)).To(Equal("my-space"))
Expect(config.SpaceFields().GUID).To(Equal("my-space-guid"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
})
It("only updates the organization in the config when the space can't be found", func() {
config.SetSpaceFields(models.SpaceFields{})
spaceRepo.FindByNameReturns(models.Space{}, errors.New("Error finding space by name."))
callTarget([]string{"-o", "my-organization", "-s", "my-space"})
Expect(orgRepo.FindByNameCallCount()).To(Equal(1))
Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-organization"))
Expect(config.OrganizationFields().GUID).To(Equal("my-organization-guid"))
Expect(spaceRepo.FindByNameCallCount()).To(Equal(1))
Expect(spaceRepo.FindByNameArgsForCall(0)).To(Equal("my-space"))
Expect(config.SpaceFields().GUID).To(Equal(""))
Expect(ui.ShowConfigurationCalled).To(BeFalse())
Expect(ui.Outputs()).To(ContainSubstrings(
示例3:
config.SetAccessToken("the-token")
Expect(config.AccessToken()).To(Equal("the-token"))
config.SetSSHOAuthClient("oauth-client-id")
Expect(config.SSHOAuthClient()).To(Equal("oauth-client-id"))
config.SetRefreshToken("the-token")
Expect(config.RefreshToken()).To(Equal("the-token"))
organization := models.OrganizationFields{Name: "the-org"}
config.SetOrganizationFields(organization)
Expect(config.OrganizationFields()).To(Equal(organization))
space := models.SpaceFields{Name: "the-space"}
config.SetSpaceFields(space)
Expect(config.SpaceFields()).To(Equal(space))
config.SetSSLDisabled(false)
Expect(config.IsSSLDisabled()).To(BeFalse())
config.SetLocale("en_US")
Expect(config.Locale()).To(Equal("en_US"))
config.SetPluginRepo(models.PluginRepo{Name: "repo", URL: "nowhere.com"})
Expect(config.PluginRepos()[0].Name).To(Equal("repo"))
Expect(config.PluginRepos()[0].URL).To(Equal("nowhere.com"))
s, _ := semver.Make("3.1")
Expect(config.IsMinAPIVersion(s)).To(Equal(false))
示例4:
))
Expect(spaceRepo.DeleteArgsForCall(0)).To(Equal("space-to-delete-guid"))
Expect(config.HasSpace()).To(Equal(true))
})
It("does not prompt when the -f flag is given", func() {
runCommand("-f", "space-to-delete")
Expect(ui.Prompts).To(BeEmpty())
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Deleting", "space-to-delete"},
[]string{"OK"},
))
Expect(spaceRepo.DeleteArgsForCall(0)).To(Equal("space-to-delete-guid"))
})
It("clears the space from the config, when deleting the space currently targeted", func() {
config.SetSpaceFields(space.SpaceFields)
runCommand("-f", "space-to-delete")
Expect(config.HasSpace()).To(Equal(false))
})
It("clears the space from the config, when deleting the space currently targeted even if space name is case insensitive", func() {
config.SetSpaceFields(space.SpaceFields)
runCommand("-f", "Space-To-Delete")
Expect(config.HasSpace()).To(Equal(false))
})
})
示例5:
requirementsFactory.NewSpaceRequirementReturns(spaceReq)
})
It("renames a space", func() {
originalSpaceName := configRepo.SpaceFields().Name
callRenameSpace([]string{"the-old-space-name", "my-new-space"})
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Renaming space", "the-old-space-name", "my-new-space", "my-org", "my-user"},
[]string{"OK"},
))
spaceGUID, name := spaceRepo.RenameArgsForCall(0)
Expect(spaceGUID).To(Equal("the-old-space-guid"))
Expect(name).To(Equal("my-new-space"))
Expect(configRepo.SpaceFields().Name).To(Equal(originalSpaceName))
})
Describe("renaming the space the user has targeted", func() {
BeforeEach(func() {
configRepo.SetSpaceFields(space.SpaceFields)
})
It("renames the targeted space", func() {
callRenameSpace([]string{"the-old-space-name", "my-new-space-name"})
Expect(configRepo.SpaceFields().Name).To(Equal("my-new-space-name"))
})
})
})
})