當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ReadWriter.SetSpaceFields方法代碼示例

本文整理匯總了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"))
			})
		})
	})
})
開發者ID:BlueSpice,項目名稱:cli,代碼行數:30,代碼來源:rename_space_test.go

示例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(""))
開發者ID:GABONIA,項目名稱:cli,代碼行數:31,代碼來源:target_test.go

示例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"},
開發者ID:BlueSpice,項目名稱:cli,代碼行數:32,代碼來源:marketplace_test.go

示例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())
			})
開發者ID:BlueSpice,項目名稱:cli,代碼行數:29,代碼來源:endpoints_test.go

示例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)
			})
開發者ID:GABONIA,項目名稱:cli,代碼行數:31,代碼來源:ui_test.go

示例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))
	})
})
開發者ID:GABONIA,項目名稱:cli,代碼行數:30,代碼來源:delete_space_test.go


注:本文中的github.com/cloudfoundry/cli/cf/configuration.ReadWriter.SetSpaceFields方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。