本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/api/spaces/spacesfakes.FakeSpaceRepository.FindByNameInOrgReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeSpaceRepository.FindByNameInOrgReturns方法的具體用法?Golang FakeSpaceRepository.FindByNameInOrgReturns怎麽用?Golang FakeSpaceRepository.FindByNameInOrgReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/cloudfoundry/org/cli/cf/api/spaces/spacesfakes.FakeSpaceRepository
的用法示例。
在下文中一共展示了FakeSpaceRepository.FindByNameInOrgReturns方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
Expect(runCommand("my-org", "my-space")).To(BeFalse())
})
It("succeeds when logged in", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
organizationReq := new(requirementsfakes.FakeOrganizationRequirement)
organizationReq.GetOrganizationReturns(
models.Organization{
OrganizationFields: models.OrganizationFields{
Name: "some-org",
},
},
)
spaceRepo.FindByNameInOrgReturns(
models.Space{
SpaceFields: models.SpaceFields{
Name: "whatever-space",
},
}, nil)
requirementsFactory.NewOrganizationRequirementReturns(organizationReq)
passed := runCommand("some-org", "whatever-space")
Expect(passed).To(BeTrue())
Expect(ui.Outputs()).To(ContainSubstrings([]string{"Getting users in org some-org / space whatever-space as my-user"}))
})
})
It("fails with usage when not invoked with exactly two args", func() {
runCommand("my-org")
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires arguments"},
))
示例2:
Expect(fakeOrgRepo.FindByNameArgsForCall(0)).To(Equal("org"))
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"Org", "org", "not found"},
))
})
})
Context("when the space does not exist", func() {
BeforeEach(func() {
org := models.Organization{}
org.Name = "org-name"
org.GUID = "org-guid"
fakeOrgRepo.ListOrgsReturns([]models.Organization{org}, nil)
fakeOrgRepo.FindByNameReturns(org, nil)
fakeSpaceRepo.FindByNameInOrgReturns(models.Space{}, errors.NewModelNotFoundError("Space", "space-name"))
})
It("fails and tells the user", func() {
runCommand("sec group", "org-name", "space-name")
name, orgGUID := fakeSpaceRepo.FindByNameInOrgArgsForCall(0)
Expect(name).To(Equal("space-name"))
Expect(orgGUID).To(Equal("org-guid"))
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"Space", "space-name", "not found"},
))
})
})
示例3:
GUID: "my-group-guid",
Rules: []map[string]interface{}{},
},
}
securityGroupRepo.ReadReturns(securityGroup, nil)
orgRepo.ListOrgsReturns([]models.Organization{{
OrganizationFields: models.OrganizationFields{
Name: "my-org",
GUID: "my-org-guid",
}},
}, nil)
space := models.Space{SpaceFields: models.SpaceFields{Name: "my-space", GUID: "my-space-guid"}}
spaceRepo.FindByNameInOrgReturns(space, nil)
})
It("removes the security group when we only pass the security group name (using the targeted org and space)", func() {
runCommand("my-group")
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Unbinding security group", "my-org", "my-space", "my-user"},
[]string{"OK"},
))
securityGroupGUID, spaceGUID := secBinder.UnbindSpaceArgsForCall(0)
Expect(securityGroupGUID).To(Equal("my-group-guid"))
Expect(spaceGUID).To(Equal("my-space-guid"))
})
It("removes the security group when we pass the org and space", func() {
示例4:
flagContext.Parse("the-user-name", "the-org-name", "the-space-name", "SpaceManager")
cmd.Requirements(factory, flagContext)
org = models.Organization{}
org.GUID = "the-org-guid"
org.Name = "the-org-name"
organizationRequirement.GetOrganizationReturns(org)
})
JustBeforeEach(func() {
err = cmd.Execute(flagContext)
})
Context("when the space is not found", func() {
BeforeEach(func() {
spaceRepo.FindByNameInOrgReturns(models.Space{}, errors.New("space-repo-error"))
})
It("doesn't call CC", func() {
Expect(userRepo.UnsetSpaceRoleByGUIDCallCount()).To(BeZero())
Expect(userRepo.UnsetSpaceRoleByUsernameCallCount()).To(BeZero())
})
It("return an error", func() {
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("space-repo-error"))
})
})
Context("when the space is found", func() {
BeforeEach(func() {