本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/configuration/coreconfig.ReadWriter.SetOrganizationFields方法的典型用法代码示例。如果您正苦于以下问题:Golang ReadWriter.SetOrganizationFields方法的具体用法?Golang ReadWriter.SetOrganizationFields怎么用?Golang ReadWriter.SetOrganizationFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/configuration/coreconfig.ReadWriter
的用法示例。
在下文中一共展示了ReadWriter.SetOrganizationFields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
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",
})
})
示例2:
"github.com/cloudfoundry/cli/cf/api/apifakes"
"github.com/cloudfoundry/cli/cf/configuration/coreconfig"
"github.com/cloudfoundry/cli/cf/errors"
"github.com/cloudfoundry/cli/cf/models"
. "github.com/cloudfoundry/cli/cf/requirements"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("DomainRequirement", func() {
var config coreconfig.ReadWriter
BeforeEach(func() {
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 := new(apifakes.FakeDomainRepository)
domainRepo.FindByNameInOrgReturns(domain, nil)
domainReq := NewDomainRequirement("example.com", config, domainRepo)
err := domainReq.Execute()
Expect(err).NotTo(HaveOccurred())
orgName, orgGUID := domainRepo.FindByNameInOrgArgsForCall(0)
Expect(orgName).To(Equal("example.com"))
Expect(orgGUID).To(Equal("the-org-guid"))
Expect(domainReq.GetDomain()).To(Equal(domain))
})
示例3:
})
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"
coreConfig.SetOrganizationFields(org)
coreConfig.SetSpaceFields(space)
testServerFn = validAPIInfoEndpoint
})
It("returns the configuration info from /info", func() {
config, endpoint, err := repo.GetCCInfo(testServer.URL)
Expect(err).NotTo(HaveOccurred())
Expect(config.AuthorizationEndpoint).To(Equal("https://login.example.com"))
Expect(config.LoggregatorEndpoint).To(Equal("wss://loggregator.foo.example.org:4443"))
Expect(endpoint).To(Equal(testServer.URL))
Expect(config.SSHOAuthClient).To(Equal("ssh-client-id"))
Expect(config.APIVersion).To(Equal("42.0.0"))
Expect(config.MinCLIVersion).To(Equal("6.5.0"))
Expect(config.MinRecommendedCLIVersion).To(Equal("6.7.0"))
示例4:
)
var _ = Describe("TargetedOrganizationRequirement", func() {
var (
config coreconfig.ReadWriter
)
BeforeEach(func() {
config = testconfig.NewRepositoryWithDefaults()
})
Context("when the user has an org targeted", func() {
It("succeeds", func() {
req := NewTargetedOrgRequirement(config)
err := req.Execute()
Expect(err).NotTo(HaveOccurred())
})
})
Context("when the user does not have an org targeted", func() {
It("errors", func() {
config.SetOrganizationFields(models.OrganizationFields{})
err := NewTargetedOrgRequirement(config).Execute()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("No org targeted"))
})
})
})