本文整理汇总了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() {