本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/requirements/requirementsfakes.FakeTargetedOrgRequirement类的典型用法代码示例。如果您正苦于以下问题:Golang FakeTargetedOrgRequirement类的具体用法?Golang FakeTargetedOrgRequirement怎么用?Golang FakeTargetedOrgRequirement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FakeTargetedOrgRequirement类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
"github.com/cloudfoundry/cli/cf/commands/spacequota"
"github.com/cloudfoundry/cli/cf/flags"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("create-space-quota", func() {
var (
ui *testterm.FakeUI
quotaRepo *spacequotasfakes.FakeSpaceQuotaRepository
requirementsFactory *requirementsfakes.FakeFactory
config *coreconfigfakes.FakeRepository
loginReq *requirementsfakes.FakeRequirement
targetedOrgReq *requirementsfakes.FakeTargetedOrgRequirement
minApiVersionReq *requirementsfakes.FakeRequirement
reqFactory *requirementsfakes.FakeFactory
deps commandregistry.Dependency
cmd spacequota.CreateSpaceQuota
flagContext flags.FlagContext
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
quotaRepo = new(spacequotasfakes.FakeSpaceQuotaRepository)
requirementsFactory = new(requirementsfakes.FakeFactory)
config = new(coreconfigfakes.FakeRepository)
repoLocator := api.RepositoryLocator{}
示例2:
It("fails with usage when called without enough arguments", func() {
runCommand()
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() {
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.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
spaceReq := new(requirementsfakes.FakeSpaceRequirement)
spaceReq.ExecuteReturns(errors.New("no space"))
requirementsFactory.NewSpaceRequirementReturns(spaceReq)
Expect(runCommand("my-space")).To(BeFalse())
})
})
示例3:
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
configRepo = testconfig.NewRepositoryWithDefaults()
})
runCommand := func(args ...string) bool {
return testcmd.RunCLICommand("space-quotas", args, requirementsFactory, updateCommandDependency, false, ui)
}
Describe("requirements", func() {
It("requires the user to be logged in", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
Expect(runCommand()).ToNot(HavePassedRequirements())
})
It("requires the user to target an org", func() {
orgReq := new(requirementsfakes.FakeTargetedOrgRequirement)
orgReq.ExecuteReturns(errors.New("not targeting org"))
requirementsFactory.NewTargetedOrgRequirementReturns(orgReq)
Expect(runCommand()).ToNot(HavePassedRequirements())
})
Context("when arguments are provided", func() {
var cmd commandregistry.Command
var flagContext flags.FlagContext
BeforeEach(func() {
cmd = &spacequota.ListSpaceQuotas{}
cmd.SetDependency(deps, false)
flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
})
示例4:
})
runCommand := func(args ...string) bool {
return testcmd.RunCLICommand("delete-shared-domain", args, requirementsFactory, updateCommandDependency, false, ui)
}
Describe("requirements", func() {
It("fails if you are not logged in", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
Expect(runCommand("foo.com")).To(BeFalse())
})
It("fails if an organiztion is not targeted", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
targetedOrganizationReq := new(requirementsfakes.FakeTargetedOrgRequirement)
targetedOrganizationReq.ExecuteReturns(errors.New("not targeted"))
requirementsFactory.NewTargetedOrgRequirementReturns(targetedOrganizationReq)
Expect(runCommand("foo.com")).To(BeFalse())
})
})
Context("when the domain is owned", func() {
BeforeEach(func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
domainRepo.FindByNameInOrgReturns(
models.DomainFields{
Name: "foo1.com",
GUID: "foo1-guid",