本文整理匯總了Golang中github.com/nttlabs/cli/cf/api/fakes.FakeSpaceRepository.Spaces方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeSpaceRepository.Spaces方法的具體用法?Golang FakeSpaceRepository.Spaces怎麽用?Golang FakeSpaceRepository.Spaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nttlabs/cli/cf/api/fakes.FakeSpaceRepository
的用法示例。
在下文中一共展示了FakeSpaceRepository.Spaces方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
It("fails when an org is not targeted", func() {
requirementsFactory.LoginSuccess = true
runCommand()
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
})
})
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:
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"},
示例3:
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"},
))
示例4:
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"},
示例5:
requirementsFactory.TargetedOrgSuccess = true
})
It("unassigns a quota from a space", func() {
space := models.Space{
SpaceFields: models.SpaceFields{
Name: "my-space",
Guid: "my-space-guid",
},
}
quota := models.SpaceQuota{Name: "my-quota", Guid: "my-quota-guid"}
quotaRepo.FindByNameReturns(quota, nil)
spaceRepo.FindByNameName = space.Name
spaceRepo.Spaces = []models.Space{space}
runCommand("my-space", "my-quota")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Unassigning space quota", "my-quota", "my-space", "my-user"},
[]string{"OK"},
))
Expect(quotaRepo.FindByNameArgsForCall(0)).To(Equal("my-quota"))
spaceGuid, quotaGuid := quotaRepo.UnassignQuotaFromSpaceArgsForCall(0)
Expect(spaceGuid).To(Equal("my-space-guid"))
Expect(quotaGuid).To(Equal("my-quota-guid"))
})
})
})