本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/requirements/requirementsfakes.FakeFactory.NewTargetedOrgRequirementReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeFactory.NewTargetedOrgRequirementReturns方法的具體用法?Golang FakeFactory.NewTargetedOrgRequirementReturns怎麽用?Golang FakeFactory.NewTargetedOrgRequirementReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/cloudfoundry/org/cli/cf/requirements/requirementsfakes.FakeFactory
的用法示例。
在下文中一共展示了FakeFactory.NewTargetedOrgRequirementReturns方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires", "argument"},
))
})
It("fails requirements when not logged in", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
Expect(runCommand("my-space")).To(BeFalse())
})
It("does not pass requirements if org is not targeted", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
targetedOrgReq := new(requirementsfakes.FakeTargetedOrgRequirement)
targetedOrgReq.ExecuteReturns(errors.New("no org targeted"))
requirementsFactory.NewTargetedOrgRequirementReturns(targetedOrgReq)
Expect(runCommand("my-space")).To(BeFalse())
})
It("does not pass requirements if space does not exist", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
spaceReq := new(requirementsfakes.FakeSpaceRequirement)
spaceReq.ExecuteReturns(errors.New("no space"))
requirementsFactory.NewSpaceRequirementReturns(spaceReq)
Expect(runCommand("my-space")).To(BeFalse())
})
})
示例2:
requirementsFactory *requirementsfakes.FakeFactory
configRepo *coreconfigfakes.FakeRepository
deps commandregistry.Dependency
cmd spacequota.SetSpaceQuota
flagContext flags.FlagContext
loginReq requirements.Requirement
orgReq *requirementsfakes.FakeTargetedOrgRequirement
)
BeforeEach(func() {
requirementsFactory = new(requirementsfakes.FakeFactory)
loginReq = requirements.Passing{Type: "login"}
requirementsFactory.NewLoginRequirementReturns(loginReq)
orgReq = new(requirementsfakes.FakeTargetedOrgRequirement)
requirementsFactory.NewTargetedOrgRequirementReturns(orgReq)
ui = new(testterm.FakeUI)
configRepo = new(coreconfigfakes.FakeRepository)
deps = commandregistry.Dependency{
UI: ui,
Config: configRepo,
}
quotaRepo = new(spacequotasfakes.FakeSpaceQuotaRepository)
deps.RepoLocator = deps.RepoLocator.SetSpaceQuotaRepository(quotaRepo)
spaceRepo = new(spacesfakes.FakeSpaceRepository)
deps.RepoLocator = deps.RepoLocator.SetSpaceRepository(spaceRepo)
flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
cmd = spacequota.SetSpaceQuota{}
示例3:
Config: configRepo,
RepoLocator: repoLocator,
}
cmd = &route.CheckRoute{}
cmd.SetDependency(deps, false)
flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
factory = new(requirementsfakes.FakeFactory)
loginRequirement = &passingRequirement{Name: "login-requirement"}
factory.NewLoginRequirementReturns(loginRequirement)
targetedOrgRequirement = new(requirementsfakes.FakeTargetedOrgRequirement)
factory.NewTargetedOrgRequirementReturns(targetedOrgRequirement)
minAPIVersionRequirement = &passingRequirement{Name: "min-api-version-requirement"}
factory.NewMinAPIVersionRequirementReturns(minAPIVersionRequirement)
})
Describe("Requirements", func() {
Context("when not provided exactly two args", func() {
BeforeEach(func() {
flagContext.Parse("app-name")
})
It("fails with usage", func() {
_, err := cmd.Requirements(factory, flagContext)
Expect(err).To(HaveOccurred())
Expect(ui.Outputs()).To(ContainSubstrings(
示例4:
deps = commandregistry.Dependency{
UI: ui,
Config: config,
RepoLocator: repoLocator,
}
reqFactory = new(requirementsfakes.FakeFactory)
loginReq = new(requirementsfakes.FakeRequirement)
loginReq.ExecuteReturns(nil)
reqFactory.NewLoginRequirementReturns(loginReq)
targetedOrgReq = new(requirementsfakes.FakeTargetedOrgRequirement)
targetedOrgReq.ExecuteReturns(nil)
reqFactory.NewTargetedOrgRequirementReturns(targetedOrgReq)
minApiVersionReq = new(requirementsfakes.FakeRequirement)
minApiVersionReq.ExecuteReturns(nil)
reqFactory.NewMinAPIVersionRequirementReturns(minApiVersionReq)
cmd = spacequota.CreateSpaceQuota{}
flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
})
Describe("Requirements", func() {
BeforeEach(func() {
cmd.SetDependency(deps, false)
})
Context("when not exactly one arg is provided", func() {
It("fails", func() {