本文整理匯總了Golang中cf/configuration.ReadWriter.SetOrganizationFields方法的典型用法代碼示例。如果您正苦於以下問題:Golang ReadWriter.SetOrganizationFields方法的具體用法?Golang ReadWriter.SetOrganizationFields怎麽用?Golang ReadWriter.SetOrganizationFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf/configuration.ReadWriter
的用法示例。
在下文中一共展示了ReadWriter.SetOrganizationFields方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
testassert.SliceContains(ui.Outputs, testassert.Lines{{"FAILED"}})
})
It("TestTargetOrganizationWhenOrgNotFound", func() {
orgRepo.FindByNameNotFound = true
ui := callTarget([]string{"-o", "my-organization"}, reqFactory, config, orgRepo, spaceRepo)
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"FAILED"},
{"my-organization", "not found"},
})
})
It("TestTargetSpaceWhenNoOrganizationIsSelected", func() {
config.SetOrganizationFields(models.OrganizationFields{})
ui := callTarget([]string{"-s", "my-space"}, reqFactory, config, orgRepo, spaceRepo)
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"FAILED"},
{"An org must be targeted before targeting a space"},
})
Expect(config.OrganizationFields().Guid).To(Equal(""))
})
It("TestTargetSpaceWhenUserHasAccess", func() {
space := models.Space{}
space.Name = "my-space"
space.Guid = "my-space-guid"
示例2:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testconfig "testhelpers/configuration"
testterm "testhelpers/terminal"
)
var _ = Describe("Testing with ginkgo", func() {
var config configuration.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: 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() {
示例3:
It("tells the user the api version", func() {
testassert.SliceContains(output, testassert.Lines{
{"API version:", "☃☃☃"},
})
})
It("tells the user which user is logged in", func() {
testassert.SliceContains(output, testassert.Lines{
{"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() {
testassert.SliceContains(output, testassert.Lines{
{"Org:", "org-name"},
})
})
})
Context("when a space is targeted", func() {
BeforeEach(func() {
config.SetSpaceFields(models.SpaceFields{
Name: "my-space",
Guid: "space-guid",
示例4:
testServer.Close()
})
Describe("updating the endpoints", func() {
It("stores the data from the /info api in the config", func() {
testServerFn = validApiInfoEndpoint
org := models.OrganizationFields{}
org.Name = "my-org"
org.Guid = "my-org-guid"
space := models.SpaceFields{}
space.Name = "my-space"
space.Guid = "my-space-guid"
config.SetOrganizationFields(org)
config.SetSpaceFields(space)
repo.UpdateEndpoint(testServer.URL)
Expect(config.AccessToken()).To(Equal(""))
Expect(config.AuthorizationEndpoint()).To(Equal("https://login.example.com"))
Expect(config.LoggregatorEndpoint()).To(Equal("wss://loggregator.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())
})
It("TestUpdateEndpointWhenUrlIsAlreadyTargeted", func() {
testServerFn = validApiInfoEndpoint
示例5:
Expect(testcmd.CommandDidPassRequirements).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(orgRepo.Organizations[0].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{}
示例6:
callRenameOrg([]string{"the-old-org-name", "the-new-org-name"})
Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
})
It("renames an organization", func() {
targetedOrgName := configRepo.OrganizationFields().Name
callRenameOrg([]string{"the-old-org-name", "the-new-org-name"})
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Renaming org", "the-old-org-name", "the-new-org-name", "my-user"},
{"OK"},
})
Expect(requirementsFactory.OrganizationName).To(Equal("the-old-org-name"))
Expect(orgRepo.RenameOrganizationGuid).To(Equal("the-old-org-guid"))
Expect(orgRepo.RenameNewName).To(Equal("the-new-org-name"))
Expect(configRepo.OrganizationFields().Name).To(Equal(targetedOrgName))
})
Describe("when the organization is currently targetted", 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"))
})
})
})
})
示例7:
Expect(Config.RefreshToken()).To(Equal("my_refresh_token"))
Expect(endpointRepo.UpdateEndpointReceived).To(Equal("api.example.com"))
Expect(authRepo.AuthenticateArgs.Credentials).To(Equal(map[string]string{
"username": "[email protected]",
"password": "password",
}))
Expect(orgRepo.FindByNameName).To(Equal("my-org"))
Expect(spaceRepo.FindByNameName).To(Equal("my-space"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
})
It("doesn't ask the user to select an org if they have one in their config", func() {
Config.SetOrganizationFields(org2.OrganizationFields)
Flags = []string{"-s", "my-space"}
ui.Inputs = []string{"http://api.example.com", "[email protected]", "password"}
orgRepo.FindByNameOrganization = models.Organization{}
l := NewLogin(ui, Config, authRepo, endpointRepo, orgRepo, spaceRepo)
testcmd.RunCommand(l, testcmd.NewContext("login", Flags), nil)
Expect(Config.ApiEndpoint()).To(Equal("http://api.example.com"))
Expect(Config.OrganizationFields().Guid).To(Equal("my-org-guid"))
Expect(Config.SpaceFields().Guid).To(Equal("my-space-guid"))
Expect(Config.AccessToken()).To(Equal("my_access_token"))
Expect(Config.RefreshToken()).To(Equal("my_refresh_token"))