本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/configuration/core_config.Repository.SetOrganizationFields方法的典型用法代碼示例。如果您正苦於以下問題:Golang Repository.SetOrganizationFields方法的具體用法?Golang Repository.SetOrganizationFields怎麽用?Golang Repository.SetOrganizationFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/cli/cf/configuration/core_config.Repository
的用法示例。
在下文中一共展示了Repository.SetOrganizationFields方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
It("fails when the organization is not found", func() {
orgRepo.FindByNameReturns(models.Organization{}, errors.New("my-organization not found"))
callTarget([]string{"-o", "my-organization"})
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"my-organization", "not found"},
))
expectOrgToBeCleared()
expectSpaceToBeCleared()
})
It("fails to target a space if no organization is targeted", func() {
config.SetOrganizationFields(models.OrganizationFields{})
callTarget([]string{"-s", "my-space"})
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"An org must be targeted before targeting a space"},
))
expectSpaceToBeCleared()
})
It("fails when the user doesn't have access to the space", func() {
spaceRepo.FindByNameReturns(models.Space{}, errors.New("Error finding space by name."))
callTarget([]string{"-s", "my-space"})
示例2:
AfterEach(func() {
rpcService.Stop()
//give time for server to stop
time.Sleep(50 * time.Millisecond)
})
Context(".GetCurrentOrg", func() {
BeforeEach(func() {
config.SetOrganizationFields(models.OrganizationFields{
Guid: "test-guid",
Name: "test-org",
QuotaDefinition: models.QuotaFields{
Guid: "guid123",
Name: "quota123",
MemoryLimit: 128,
InstanceMemoryLimit: 16,
RoutesLimit: 5,
ServicesLimit: 6,
NonBasicServicesAllowed: true,
},
})
rpcService, err = NewRpcService(nil, nil, nil, config)
err := rpcService.Start()
Expect(err).ToNot(HaveOccurred())
pingCli(rpcService.Port())
})
It("populates the plugin Organization object with the current org settings in config", func() {
示例3:
Expect(config.DopplerEndpoint()).To(Equal("http://doppler.the-endpoint"))
config.SetUaaEndpoint("http://uaa.the-endpoint")
Expect(config.UaaEndpoint()).To(Equal("http://uaa.the-endpoint"))
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 := maker.NewOrgFields(maker.Overrides{"name": "the-org"})
config.SetOrganizationFields(organization)
Expect(config.OrganizationFields()).To(Equal(organization))
space := maker.NewSpaceFields(maker.Overrides{"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"))
示例4:
})
It("renames an organization", func() {
targetedOrgName := configRepo.OrganizationFields().Name
callRenameOrg([]string{"the-old-org-name", "the-new-org-name"})
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Renaming org", "the-old-org-name", "the-new-org-name", "my-user"},
[]string{"OK"},
))
guid, name := orgRepo.RenameArgsForCall(0)
Expect(requirementsFactory.OrganizationName).To(Equal("the-old-org-name"))
Expect(guid).To(Equal("the-old-org-guid"))
Expect(name).To(Equal("the-new-org-name"))
Expect(configRepo.OrganizationFields().Name).To(Equal(targetedOrgName))
})
Describe("when the organization is currently targeted", func() {
It("updates the name of the org in the config", func() {
configRepo.SetOrganizationFields(models.OrganizationFields{
Guid: "the-old-org-guid",
Name: "the-old-org-name",
})
callRenameOrg([]string{"the-old-org-name", "the-new-org-name"})
Expect(configRepo.OrganizationFields().Name).To(Equal("the-new-org-name"))
})
})
})
})
示例5:
It("fails with usage if no arguments are given", func() {
runCommand()
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires an argument"},
))
})
Context("when logged in", func() {
BeforeEach(func() {
requirementsFactory.LoginSuccess = true
})
Context("when deleting the currently targeted org", func() {
It("untargets the deleted org", func() {
config.SetOrganizationFields(org.OrganizationFields)
runCommand("org-to-delete")
Expect(config.OrganizationFields()).To(Equal(models.OrganizationFields{}))
Expect(config.SpaceFields()).To(Equal(models.SpaceFields{}))
})
})
Context("when deleting an org that is not targeted", func() {
BeforeEach(func() {
otherOrgFields := models.OrganizationFields{}
otherOrgFields.Guid = "some-other-org-guid"
otherOrgFields.Name = "some-other-org"
config.SetOrganizationFields(otherOrgFields)
spaceFields := models.SpaceFields{}