本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/api/fakes.FakeSpaceRepository.Spaces方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeSpaceRepository.Spaces方法的具体用法?Golang FakeSpaceRepository.Spaces怎么用?Golang FakeSpaceRepository.Spaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/api/fakes.FakeSpaceRepository
的用法示例。
在下文中一共展示了FakeSpaceRepository.Spaces方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
It("should fail with usage when provided any arguments", func() {
requirementsFactory.LoginSuccess = true
Expect(runCommand("blahblah")).To(BeFalse())
Expect(ui.FailedWithUsage).To(BeTrue())
})
})
Context("when logged in and an org is targeted", func() {
BeforeEach(func() {
space := models.Space{}
space.Name = "space1"
space2 := models.Space{}
space2.Name = "space2"
space3 := models.Space{}
space3.Name = "space3"
spaceRepo.Spaces = []models.Space{space, space2, space3}
requirementsFactory.LoginSuccess = true
requirementsFactory.TargetedOrgSuccess = true
})
It("lists all of the spaces", func() {
runCommand()
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Getting spaces in org", "my-org", "my-user"},
[]string{"space1"},
[]string{"space2"},
[]string{"space3"},
))
})
示例2:
runCommand("source-app", "target-app")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"could not find target app"},
))
})
})
})
Describe("when a space is provided, but not an org", func() {
It("send the correct target appplication for the current org and target space", func() {
spaceRepo.Spaces = []models.Space{
{
SpaceFields: models.SpaceFields{
Name: "space-name",
Guid: "model-space-guid",
},
},
}
runCommand("-s", "space-name", "source-app", "target-app")
targetAppName, spaceGuid := appRepo.ReadFromSpaceArgsForCall(0)
Expect(targetAppName).To(Equal("target-app"))
Expect(spaceGuid).To(Equal("model-space-guid"))
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Copying source from app", "source-app", "to target app", "target-app", "in org my-org / space space-name as my-user..."},
[]string{"Note: this may take some time"},
[]string{"OK"},
))
示例3:
orgRepo.FindByNameOrganization = org
callTarget([]string{"-o", "my-organization"})
Expect(orgRepo.FindByNameName).To(Equal("my-organization"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
Expect(config.OrganizationFields().Guid).To(Equal("my-organization-guid"))
})
It("updates the space in the config", func() {
space := models.Space{}
space.Name = "my-space"
space.Guid = "my-space-guid"
spaceRepo.Spaces = []models.Space{space}
spaceRepo.FindByNameSpace = space
callTarget([]string{"-s", "my-space"})
Expect(spaceRepo.FindByNameName).To(Equal("my-space"))
Expect(config.SpaceFields().Guid).To(Equal("my-space-guid"))
Expect(ui.ShowConfigurationCalled).To(BeTrue())
})
It("updates both the organization and the space in the config", func() {
org := models.Organization{}
org.Name = "my-organization"
org.Guid = "my-organization-guid"
orgRepo.Organizations = []models.Organization{org}
示例4:
models.SpaceQuota{
Name: "quota-name",
Guid: "quota-guid",
MemoryLimit: 1024,
InstanceMemoryLimit: 512,
RoutesLimit: 111,
ServicesLimit: 222,
NonBasicServicesAllowed: true,
OrgGuid: "my-org-guid",
}, nil)
spaceRepo.Spaces = []models.Space{
models.Space{
SpaceFields: models.SpaceFields{
Name: "my-space",
Guid: "my-space-guid",
},
SpaceQuotaGuid: "",
},
}
})
Context("when the space quota was not previously assigned to a space", func() {
It("associates the provided space with the provided space quota", func() {
spaceGuid, quotaGuid := quotaRepo.AssociateSpaceWithQuotaArgsForCall(0)
Expect(spaceGuid).To(Equal("my-space-guid"))
Expect(quotaGuid).To(Equal("quota-guid"))
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Assigning space quota", "to space", "my-user"},
[]string{"OK"},
示例5:
org1.Name = "some-org"
org2 = models.Organization{}
org2.Guid = "my-new-org-guid"
org2.Name = "my-new-org"
space1 := models.Space{}
space1.Guid = "my-space-guid"
space1.Name = "my-space"
space2 = models.Space{}
space2.Guid = "some-space-guid"
space2.Name = "some-space"
orgRepo.ListOrgsReturns([]models.Organization{org1, org2}, nil)
spaceRepo.Spaces = []models.Space{space1, space2}
})
It("lets the user select an org and space by number", func() {
orgRepo.FindByNameReturns(org2, nil)
OUT_OF_RANGE_CHOICE := "3"
ui.Inputs = []string{"api.example.com", "[email protected]", "password", OUT_OF_RANGE_CHOICE, "2", OUT_OF_RANGE_CHOICE, "1"}
l := NewLogin(ui, Config, authRepo, endpointRepo, orgRepo, spaceRepo)
testcmd.RunCommand(l, Flags, nil)
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Select an org"},
[]string{"1. some-org"},
[]string{"2. my-new-org"},
[]string{"Select a space"},