本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/configuration/coreconfig.Repository.SetSpaceFields方法的典型用法代码示例。如果您正苦于以下问题:Golang Repository.SetSpaceFields方法的具体用法?Golang Repository.SetSpaceFields怎么用?Golang Repository.SetSpaceFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/configuration/coreconfig.Repository
的用法示例。
在下文中一共展示了Repository.SetSpaceFields方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
callTarget([]string{"-o", "my-organization", "-s", "my-space"})
Expect(orgRepo.FindByNameCallCount()).To(Equal(1))
Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-organization"))
Expect(config.OrganizationFields().GUID).To(Equal("my-organization-guid"))
Expect(spaceRepo.FindByNameCallCount()).To(Equal(1))
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.FindByNameCallCount()).To(Equal(1))
Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-organization"))
Expect(config.OrganizationFields().GUID).To(Equal("my-organization-guid"))
Expect(spaceRepo.FindByNameCallCount()).To(Equal(1))
Expect(spaceRepo.FindByNameArgsForCall(0)).To(Equal("my-space"))
Expect(config.SpaceFields().GUID).To(Equal(""))
Expect(ui.ShowConfigurationCalled).To(BeFalse())
Expect(ui.Outputs()).To(ContainSubstrings(
示例2:
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{}
spaceFields.Name = "some-other-space"
config.SetSpaceFields(spaceFields)
})
It("deletes the org with the given name", func() {
runCommand("org-to-delete")
Expect(ui.Prompts).To(ContainSubstrings([]string{"Really delete the org org-to-delete"}))
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Deleting", "org-to-delete"},
[]string{"OK"},
))
Expect(orgRepo.DeleteArgsForCall(0)).To(Equal("org-to-delete-guid"))
})
示例3:
client, err = rpc.Dial("tcp", "127.0.0.1:"+rpcService.Port())
Expect(err).ToNot(HaveOccurred())
var org plugin_models.Organization
err = client.Call("CliRpcCmd.GetCurrentOrg", "", &org)
Expect(err).ToNot(HaveOccurred())
Expect(org.Name).To(Equal("test-org"))
Expect(org.Guid).To(Equal("test-guid"))
})
})
Context(".GetCurrentSpace", func() {
BeforeEach(func() {
config.SetSpaceFields(models.SpaceFields{
GUID: "space-guid",
Name: "space-name",
})
rpcService, err = NewRpcService(nil, nil, config, api.RepositoryLocator{}, nil, nil, nil, rpc.DefaultServer)
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)
示例4:
requirementsFactory.NewSpaceRequirementReturns(spaceReq)
})
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(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"))
})
})
})
})
示例5:
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"
)
var _ = Describe("route repository", func() {
var (
ts *httptest.Server
handler *testnet.TestHandler
configRepo coreconfig.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, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter))
repo = NewCloudControllerRouteRepository(configRepo, gateway)
})
AfterEach(func() {
if ts != nil {
ts.Close()
}
})
Describe("List routes", func() {
It("lists routes in the current space", func() {
ts, handler = testnet.NewServer([]testnet.TestRequest{
apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
示例6:
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"))
})
})
})
})