本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/configuration/core_config.ReadWriter.SetOrganizationFields方法的典型用法代码示例。如果您正苦于以下问题:Golang ReadWriter.SetOrganizationFields方法的具体用法?Golang ReadWriter.SetOrganizationFields怎么用?Golang ReadWriter.SetOrganizationFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/configuration/core_config.ReadWriter
的用法示例。
在下文中一共展示了ReadWriter.SetOrganizationFields方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Expect(runCommand("some-org-name")).To(BeFalse())
})
It("fails with usage if no arguments are given", func() {
runCommand()
Expect(ui.FailedWithUsage).To(BeTrue())
})
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{}
示例2:
})
Describe("updating the endpoints", func() {
Context("when the API request is successful", func() {
var (
org models.OrganizationFields
space models.SpaceFields
)
BeforeEach(func() {
org.Name = "my-org"
org.Guid = "my-org-guid"
space.Name = "my-space"
space.Guid = "my-space-guid"
config.SetOrganizationFields(org)
config.SetSpaceFields(space)
testServerFn = validApiInfoEndpoint
})
It("stores the data from the /info api in the config", func() {
repo.UpdateEndpoint(testServer.URL)
Expect(config.AccessToken()).To(Equal(""))
Expect(config.AuthenticationEndpoint()).To(Equal("https://login.example.com"))
Expect(config.LoggregatorEndpoint()).To(Equal("wss://loggregator.foo.example.org:4443"))
Expect(config.DopplerEndpoint()).To(Equal("wss://doppler.foo.example.org:4443"))
Expect(config.ApiEndpoint()).To(Equal(testServer.URL))
Expect(config.ApiVersion()).To(Equal("42.0.0"))
Expect(config.HasOrganization()).To(BeFalse())
Expect(config.HasSpace()).To(BeFalse())
示例3:
. "github.com/cloudfoundry/cli/cf/requirements"
testassert "github.com/cloudfoundry/cli/testhelpers/assert"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("DomainRequirement", func() {
var config core_config.ReadWriter
var ui *testterm.FakeUI
BeforeEach(func() {
ui = new(testterm.FakeUI)
config = testconfig.NewRepository()
config.SetOrganizationFields(models.OrganizationFields{Guid: "the-org-guid"})
})
It("succeeds when the domain is found", func() {
domain := models.DomainFields{Name: "example.com", Guid: "domain-guid"}
domainRepo := &testapi.FakeDomainRepository{FindByNameInOrgDomain: []models.DomainFields{domain}}
domainReq := NewDomainRequirement("example.com", ui, config, domainRepo)
success := domainReq.Execute()
Expect(success).To(BeTrue())
Expect(domainRepo.FindByNameInOrgName).To(Equal("example.com"))
Expect(domainRepo.FindByNameInOrgGuid).To(Equal("the-org-guid"))
Expect(domainReq.GetDomain()).To(Equal(domain))
})
It("fails when the domain is not found", func() {
示例4:
It("tells the user which api endpoint is set", func() {
Expect(output).To(ContainSubstrings([]string{"API endpoint:", "https://test.example.org"}))
})
It("tells the user the api version", func() {
Expect(output).To(ContainSubstrings([]string{"API version:", "☃☃☃"}))
})
It("tells the user which user is logged in", func() {
Expect(output).To(ContainSubstrings([]string{"User:", "my-user-email"}))
})
Context("when an org is targeted", func() {
BeforeEach(func() {
config.SetOrganizationFields(models.OrganizationFields{
Name: "org-name",
Guid: "org-guid",
})
})
It("tells the user which org is targeted", func() {
Expect(output).To(ContainSubstrings([]string{"Org:", "org-name"}))
})
})
Context("when a space is targeted", func() {
BeforeEach(func() {
config.SetSpaceFields(models.SpaceFields{
Name: "my-space",
Guid: "space-guid",
})
})
示例5:
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.FindByNameErr = true
callTarget([]string{"-s", "my-space"})
示例6:
})
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"))
})
})
})
})