本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/configuration/core_config.ReadWriter.SetSpaceFields方法的典型用法代码示例。如果您正苦于以下问题:Golang ReadWriter.SetSpaceFields方法的具体用法?Golang ReadWriter.SetSpaceFields怎么用?Golang ReadWriter.SetSpaceFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/configuration/core_config.ReadWriter
的用法示例。
在下文中一共展示了ReadWriter.SetSpaceFields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
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"))
})
示例2:
config core_config.ReadWriter
)
BeforeEach(func() {
ui = new(testterm.FakeUI)
config = testconfig.NewRepositoryWithDefaults()
})
Context("when the user has targeted a space", func() {
It("succeeds", func() {
req := NewTargetedSpaceRequirement(ui, config)
Expect(req.Execute()).To(BeTrue())
})
})
Context("when the user does not have a space targeted", func() {
It("fails", func() {
config.SetSpaceFields(models.SpaceFields{})
testassert.AssertPanic(testterm.QuietPanic, func() {
NewTargetedSpaceRequirement(ui, config).Execute()
})
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"No space targeted"},
))
})
})
})
示例3:
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, NewTeePrinter())
ui.ShowConfiguration(config)
})
示例4:
requirementsFactory.ApiEndpointSuccess = true
Expect(testcmd.RunCommand(cmd, []string{"blahblah"}, requirementsFactory)).To(BeFalse())
Expect(ui.FailedWithUsage).To(BeTrue())
})
})
})
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",
})
serviceBuilder.GetServicesForSpaceWithPlansReturns(fakeServiceOfferings, nil)
})
It("lists all of the service offerings for the space", func() {
cmd := NewMarketplaceServices(ui, config, serviceBuilder)
testcmd.RunCommand(cmd, []string{}, requirementsFactory)
args := serviceBuilder.GetServicesForSpaceWithPlansArgsForCall(0)
Expect(args).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"},