本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/configuration/coreconfig.ReadWriter.SetOrganizationFields方法的典型用法代碼示例。如果您正苦於以下問題:Golang ReadWriter.SetOrganizationFields方法的具體用法?Golang ReadWriter.SetOrganizationFields怎麽用?Golang ReadWriter.SetOrganizationFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/cloudfoundry/org/cli/cf/configuration/coreconfig.ReadWriter
的用法示例。
在下文中一共展示了ReadWriter.SetOrganizationFields方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
})
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"))
示例2:
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",
})
})
示例3:
"code.cloudfoundry.org/cli/cf/api/apifakes"
"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
"code.cloudfoundry.org/cli/cf/errors"
"code.cloudfoundry.org/cli/cf/models"
. "code.cloudfoundry.org/cli/cf/requirements"
testconfig "code.cloudfoundry.org/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))
})
示例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"))
})
})
})