本文整理匯總了Golang中cf/configuration.ReadWriter.SetSpaceFields方法的典型用法代碼示例。如果您正苦於以下問題:Golang ReadWriter.SetSpaceFields方法的具體用法?Golang ReadWriter.SetSpaceFields怎麽用?Golang ReadWriter.SetSpaceFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf/configuration.ReadWriter
的用法示例。
在下文中一共展示了ReadWriter.SetSpaceFields方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
space.Guid = "the-old-space-guid"
reqFactory.Space = space
})
It("renames a space", func() {
originalSpaceName := configRepo.SpaceFields().Name
callRenameSpace([]string{"the-old-space-name", "my-new-space"})
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Renaming space", "the-old-space-name", "my-new-space", "my-org", "my-user"},
{"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(reqFactory.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:
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",
})
})
It("tells the user which space is targeted", func() {
testassert.SliceContains(output, testassert.Lines{
{"Space:", "my-space"},
})
})
})
})
It("prompts the user to target an org and space when no org or space is targeted", func() {
output := captureOutput(func() {
ui := NewUI(os.Stdin)
ui.ShowConfiguration(config)
示例3:
space := models.Space{}
space.Name = "my-space"
space.Guid = "my-space-guid"
spaceRepo.Spaces = []models.Space{space}
spaceRepo.FindByNameSpace = space
ui := callTarget([]string{"-s", "my-space"}, reqFactory, config, orgRepo, spaceRepo)
Expect(spaceRepo.FindByNameName).To(Equal("my-space"))
Expect(config.SpaceFields().Guid).To(Equal("my-space-guid"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
})
It("TestTargetSpaceWhenUserDoesNotHaveAccess", func() {
config.SetSpaceFields(models.SpaceFields{})
spaceRepo.FindByNameErr = true
ui := callTarget([]string{"-s", "my-space"}, reqFactory, config, orgRepo, spaceRepo)
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"FAILED"},
{"Unable to access space", "my-space"},
})
Expect(config.SpaceFields().Guid).To(Equal(""))
Expect(ui.ShowConfigurationCalled).To(BeFalse())
})
It("TestTargetSpaceWhenSpaceNotFound", func() {
spaceRepo.FindByNameNotFound = true
示例4:
})
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:
reqFactory.ApiEndpointSuccess = false
testcmd.RunCommand(cmd, testcmd.NewContext("marketplace", []string{}), reqFactory)
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, testcmd.NewContext("marketplace", []string{}), reqFactory)
Expect(serviceRepo.GetServiceOfferingsForSpaceArgs.SpaceGuid).To(Equal("the-space-guid"))
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Getting services from marketplace in org", "my-org", "the-space-name", "my-user"},
{"OK"},
{"service", "plans", "description"},
示例6:
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"})
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Renaming space", "the-old-space-name", "my-new-space", "my-org", "my-user"},
{"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"))
})
})
})
})
示例7:
testassert.SliceContains(ui.Prompts, testassert.Lines{
{"Really delete the space space-to-delete"},
})
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Deleting space", "space-to-delete", "my-org", "my-user"},
{"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())
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Deleting", "space-to-delete"},
{"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))
})
})
示例8:
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"))
Expect(endpointRepo.UpdateEndpointReceived).To(Equal("http://api.example.com"))
Expect(authRepo.AuthenticateArgs.Credentials).To(Equal(map[string]string{
"username": "[email protected]",
"password": "password",
}))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
})
It("uses the org and space from the config file if they are present", func() {
Config.SetOrganizationFields(org2.OrganizationFields)
Config.SetSpaceFields(space2.SpaceFields)
ui.Inputs = []string{"http://api.example.com", "[email protected]", "password"}
orgRepo.FindByNameOrganization = models.Organization{}
spaceRepo.FindByNameInOrgSpace = models.Space{}
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("some-space-guid"))
Expect(Config.AccessToken()).To(Equal("my_access_token"))
Expect(Config.RefreshToken()).To(Equal("my_refresh_token"))