本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/api/spaces/spacesfakes.FakeSpaceRepository.FindByNameReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeSpaceRepository.FindByNameReturns方法的具體用法?Golang FakeSpaceRepository.FindByNameReturns怎麽用?Golang FakeSpaceRepository.FindByNameReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/cli/cf/api/spaces/spacesfakes.FakeSpaceRepository
的用法示例。
在下文中一共展示了FakeSpaceRepository.FindByNameReturns方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
It("it updates the organization in the config", func() {
callTarget([]string{"-o", "my-organization"})
Expect(orgRepo.FindByNameCallCount()).To(Equal(1))
Expect(orgRepo.FindByNameArgsForCall(0)).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.FindByNameReturns(space, nil)
callTarget([]string{"-s", "my-space"})
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("updates both the organization and the space in the config", func() {
space := models.Space{}
space.Name = "my-space"
space.GUID = "my-space-guid"
spaceRepo.FindByNameReturns(space, nil)
示例2:
quotaRepo.FindByNameReturns(
models.SpaceQuota{
Name: "quota-name",
GUID: "quota-guid",
MemoryLimit: 1024,
InstanceMemoryLimit: 512,
RoutesLimit: 111,
ServicesLimit: 222,
NonBasicServicesAllowed: true,
OrgGUID: "my-org-guid",
}, nil)
spaceRepo.FindByNameReturns(
models.Space{
SpaceFields: models.SpaceFields{
Name: "my-space",
GUID: "my-space-guid",
},
SpaceQuotaGUID: "",
}, nil)
})
Context("when the space quota was not previously assigned to a space", func() {
It("associates the provided space with the provided space quota", func() {
Expect(executeErr).NotTo(HaveOccurred())
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() {
space := models.Space{}
space.Name = "space-name"
space.GUID = "model-space-guid"
spaceRepo.FindByNameReturns(space, nil)
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"},
))
})
Context("Failures", func() {
示例4:
It("does not update the api endpoint or ssl setting in the config", func() {
Expect(Config.APIEndpoint()).To(Equal("api.the-old-endpoint.com"))
Expect(Config.IsSSLDisabled()).To(BeTrue())
})
It("clears Org, and Space in the config", func() {
Expect(Config.OrganizationFields().GUID).To(BeEmpty())
Expect(Config.SpaceFields().GUID).To(BeEmpty())
})
})
Describe("and the login fails to target a space", func() {
BeforeEach(func() {
Flags = []string{"-u", "[email protected]", "-p", "password", "-o", "my-new-org", "-s", "nonexistent"}
orgRepo.FindByNameReturns(org, nil)
spaceRepo.FindByNameReturns(models.Space{}, errors.New("find-by-name-err"))
Config.SetSSLDisabled(true)
})
ItFails()
ItShowsTheTarget()
It("does not update the api endpoint or ssl setting in the config", func() {
Expect(Config.APIEndpoint()).To(Equal("api.the-old-endpoint.com"))
Expect(Config.IsSSLDisabled()).To(BeTrue())
})
It("updates the org in the config", func() {
Expect(Config.OrganizationFields().GUID).To(Equal("my-new-org-guid"))
})
示例5:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("SpaceRequirement", func() {
var spaceRepo *spacesfakes.FakeSpaceRepository
BeforeEach(func() {
spaceRepo = new(spacesfakes.FakeSpaceRepository)
})
Context("when a space with the given name exists", func() {
It("succeeds", func() {
space := models.Space{}
space.Name = "awesome-sauce-space"
space.GUID = "my-space-guid"
spaceRepo.FindByNameReturns(space, nil)
spaceReq := NewSpaceRequirement("awesome-sauce-space", spaceRepo)
err := spaceReq.Execute()
Expect(err).NotTo(HaveOccurred())
Expect(spaceReq.GetSpace()).To(Equal(space))
Expect(spaceRepo.FindByNameArgsForCall(0)).To(Equal("awesome-sauce-space"))
})
})
Context("when a space with the given name does not exist", func() {
It("errors", func() {
spaceError := errors.New("space-repo-err")
spaceRepo.FindByNameReturns(models.Space{}, spaceError)
示例6:
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
})
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.FindByNameReturns(space, nil)
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"))
})
})
})