本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/configuration/core_config.Repository.SetSpaceFields方法的典型用法代碼示例。如果您正苦於以下問題:Golang Repository.SetSpaceFields方法的具體用法?Golang Repository.SetSpaceFields怎麽用?Golang Repository.SetSpaceFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/cli/cf/configuration/core_config.Repository
的用法示例。
在下文中一共展示了Repository.SetSpaceFields方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
space.Guid = "my-space-guid"
spaceRepo.FindByNameReturns(space, nil)
callTarget([]string{"-o", "my-organization", "-s", "my-space"})
Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-organization"))
Expect(config.OrganizationFields().Guid).To(Equal("my-organization-guid"))
Expect(spaceRepo.FindByNameArgsForCall(0)).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{})
spaceRepo.FindByNameReturns(models.Space{}, errors.New("Error finding space by name."))
callTarget([]string{"-o", "my-organization", "-s", "my-space"})
Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-organization"))
Expect(config.OrganizationFields().Guid).To(Equal("my-organization-guid"))
Expect(spaceRepo.FindByNameArgsForCall(0)).To(Equal("my-space"))
Expect(config.SpaceFields().Guid).To(Equal(""))
Expect(ui.ShowConfigurationCalled).To(BeFalse())
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"Unable to access space", "my-space"},
示例2:
Expect(org.Name).To(Equal("test-org"))
Expect(org.Guid).To(Equal("test-guid"))
Expect(org.QuotaDefinition.Guid).To(Equal("guid123"))
Expect(org.QuotaDefinition.Name).To(Equal("quota123"))
Expect(org.QuotaDefinition.MemoryLimit).To(Equal(int64(128)))
Expect(org.QuotaDefinition.InstanceMemoryLimit).To(Equal(int64(16)))
Expect(org.QuotaDefinition.RoutesLimit).To(Equal(5))
Expect(org.QuotaDefinition.ServicesLimit).To(Equal(6))
Expect(org.QuotaDefinition.NonBasicServicesAllowed).To(BeTrue())
})
})
Context(".GetCurrentSpace", func() {
BeforeEach(func() {
config.SetSpaceFields(models.SpaceFields{
Guid: "space-guid",
Name: "space-name",
})
rpcService, err = NewRpcService(nil, nil, nil, config)
err := rpcService.Start()
Expect(err).ToNot(HaveOccurred())
pingCli(rpcService.Port())
})
It("populates the plugin Space object with the current space settings in config", func() {
client, err = rpc.Dial("tcp", "127.0.0.1:"+rpcService.Port())
Expect(err).ToNot(HaveOccurred())
var space plugin_models.Space
err = client.Call("CliRpcCmd.GetCurrentSpace", "", &space)
示例3:
))
Expect(spaceRepo.DeleteArgsForCall(0)).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.DeleteArgsForCall(0)).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))
})
It("clears the space from the config, when deleting the space currently targeted even if space name is case insensitive", func() {
config.SetSpaceFields(space.SpaceFields)
runCommand("-f", "Space-To-Delete")
Expect(config.HasSpace()).To(Equal(false))
})
})
示例4:
config.SetAccessToken("the-token")
Expect(config.AccessToken()).To(Equal("the-token"))
config.SetSSHOAuthClient("oauth-client-id")
Expect(config.SSHOAuthClient()).To(Equal("oauth-client-id"))
config.SetRefreshToken("the-token")
Expect(config.RefreshToken()).To(Equal("the-token"))
organization := maker.NewOrgFields(maker.Overrides{"name": "the-org"})
config.SetOrganizationFields(organization)
Expect(config.OrganizationFields()).To(Equal(organization))
space := maker.NewSpaceFields(maker.Overrides{"name": "the-space"})
config.SetSpaceFields(space)
Expect(config.SpaceFields()).To(Equal(space))
config.SetSSLDisabled(false)
Expect(config.IsSSLDisabled()).To(BeFalse())
config.SetLocale("en_US")
Expect(config.Locale()).To(Equal("en_US"))
config.SetPluginRepo(models.PluginRepo{Name: "repo", Url: "nowhere.com"})
Expect(config.PluginRepos()[0].Name).To(Equal("repo"))
Expect(config.PluginRepos()[0].Url).To(Equal("nowhere.com"))
Expect(config.IsMinApiVersion("3.1")).To(Equal(false))
config.SetMinCliVersion("6.5.0")
示例5:
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"},
))
spaceGUID, name := spaceRepo.RenameArgsForCall(0)
Expect(spaceGUID).To(Equal("the-old-space-guid"))
Expect(name).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"))
})
})
})
})
示例6:
. "github.com/onsi/gomega"
)
var _ = Describe("route repository", func() {
var (
ts *httptest.Server
handler *testnet.TestHandler
configRepo core_config.Repository
repo CloudControllerRouteRepository
)
BeforeEach(func() {
configRepo = testconfig.NewRepositoryWithDefaults()
configRepo.SetSpaceFields(models.SpaceFields{
Guid: "the-space-guid",
Name: "the-space-name",
})
gateway := net.NewCloudControllerGateway(configRepo, time.Now, &testterm.FakeUI{})
repo = NewCloudControllerRouteRepository(configRepo, gateway)
})
AfterEach(func() {
ts.Close()
})
Describe("List routes", func() {
It("lists routes in the current space", func() {
ts, handler = testnet.NewServer([]testnet.TestRequest{
testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/spaces/the-space-guid/routes?inline-relations-depth=1",