本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/configuration.ReadWriter.SetSpaceFields方法的典型用法代码示例。如果您正苦于以下问题:Golang ReadWriter.SetSpaceFields方法的具体用法?Golang ReadWriter.SetSpaceFields怎么用?Golang ReadWriter.SetSpaceFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/configuration.ReadWriter
的用法示例。
在下文中一共展示了ReadWriter.SetSpaceFields方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
space.Guid = "the-old-space-guid"
requirementsFactory.Space = space
})
It("renames a space", func() {
originalSpaceName := configRepo.SpaceFields().Name
callRenameSpace([]string{"the-old-space-name", "my-new-space"})
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Renaming space", "the-old-space-name", "my-new-space", "my-org", "my-user"},
[]string{"OK"},
))
Expect(spaceRepo.RenameSpaceGuid).To(Equal("the-old-space-guid"))
Expect(spaceRepo.RenameNewName).To(Equal("my-new-space"))
Expect(configRepo.SpaceFields().Name).To(Equal(originalSpaceName))
})
Describe("renaming the space the user has targeted", func() {
BeforeEach(func() {
configRepo.SetSpaceFields(requirementsFactory.Space.SpaceFields)
})
It("renames the targeted space", func() {
callRenameSpace([]string{"the-old-space-name", "my-new-space-name"})
Expect(configRepo.SpaceFields().Name).To(Equal("my-new-space-name"))
})
})
})
})
示例2:
space.Guid = "my-space-guid"
spaceRepo.Spaces = []models.Space{space}
callTarget([]string{"-o", "my-organization", "-s", "my-space"})
Expect(orgRepo.FindByNameName).To(Equal("my-organization"))
Expect(config.OrganizationFields().Guid).To(Equal("my-organization-guid"))
Expect(spaceRepo.FindByNameName).To(Equal("my-space"))
Expect(config.SpaceFields().Guid).To(Equal("my-space-guid"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
})
It("only updates the organization in the config when the space can't be found", func() {
config.SetSpaceFields(models.SpaceFields{})
org := models.Organization{}
org.Name = "my-organization"
org.Guid = "my-organization-guid"
orgRepo.Organizations = []models.Organization{org}
spaceRepo.FindByNameErr = true
callTarget([]string{"-o", "my-organization", "-s", "my-space"})
Expect(orgRepo.FindByNameName).To(Equal("my-organization"))
Expect(config.OrganizationFields().Guid).To(Equal("my-organization-guid"))
Expect(spaceRepo.FindByNameName).To(Equal("my-space"))
Expect(config.SpaceFields().Guid).To(Equal(""))
示例3:
requirementsFactory.ApiEndpointSuccess = false
testcmd.RunCommand(cmd, []string{}, requirementsFactory)
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
})
})
Context("when the user is logged in", func() {
BeforeEach(func() {
config = testconfig.NewRepositoryWithDefaults()
})
Context("when the user has a space targeted", func() {
BeforeEach(func() {
config.SetSpaceFields(models.SpaceFields{
Guid: "the-space-guid",
Name: "the-space-name",
})
})
It("lists all of the service offerings for the space", func() {
serviceRepo := &testapi.FakeServiceRepo{}
serviceRepo.GetServiceOfferingsForSpaceReturns.ServiceOfferings = fakeServiceOfferings
cmd := NewMarketplaceServices(ui, config, serviceRepo)
testcmd.RunCommand(cmd, []string{}, requirementsFactory)
Expect(serviceRepo.GetServiceOfferingsForSpaceArgs.SpaceGuid).To(Equal("the-space-guid"))
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Getting services from marketplace in org", "my-org", "the-space-name", "my-user"},
[]string{"OK"},
[]string{"service", "plans", "description"},
示例4:
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.ApiEndpoint()).To(Equal(testServer.URL))
Expect(config.ApiVersion()).To(Equal("42.0.0"))
Expect(config.HasOrganization()).To(BeFalse())
Expect(config.HasSpace()).To(BeFalse())
})
示例5:
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",
})
})
It("tells the user which space is targeted", func() {
Expect(output).To(ContainSubstrings([]string{"Space:", "my-space"}))
})
})
})
It("prompts the user to target an org and space when no org or space is targeted", func() {
output := io_helpers.CaptureOutput(func() {
ui := NewUI(os.Stdin)
ui.ShowConfiguration(config)
})
示例6:
ui.Inputs = []string{"yes"}
runCommand("space-to-delete")
Expect(ui.Prompts).To(ContainSubstrings([]string{"Really delete the space space-to-delete"}))
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Deleting space", "space-to-delete", "my-org", "my-user"},
[]string{"OK"},
))
Expect(spaceRepo.DeletedSpaceGuid).To(Equal("space-to-delete-guid"))
Expect(config.HasSpace()).To(Equal(true))
})
It("does not prompt when the -f flag is given", func() {
runCommand("-f", "space-to-delete")
Expect(ui.Prompts).To(BeEmpty())
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Deleting", "space-to-delete"},
[]string{"OK"},
))
Expect(spaceRepo.DeletedSpaceGuid).To(Equal("space-to-delete-guid"))
})
It("clears the space from the config, when deleting the space currently targeted", func() {
config.SetSpaceFields(space.SpaceFields)
runCommand("-f", "space-to-delete")
Expect(config.HasSpace()).To(Equal(false))
})
})