本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/requirements/requirementsfakes.FakeSpaceRequirement類的典型用法代碼示例。如果您正苦於以下問題:Golang FakeSpaceRequirement類的具體用法?Golang FakeSpaceRequirement怎麽用?Golang FakeSpaceRequirement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FakeSpaceRequirement類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
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())
})
})
Describe("disallow-space-ssh", func() {
var space models.Space
BeforeEach(func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
space = models.Space{}
示例2:
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("CreateRoute", func() {
var (
ui *testterm.FakeUI
routeRepo *apifakes.FakeRouteRepository
configRepo coreconfig.Repository
cmd commandregistry.Command
deps commandregistry.Dependency
factory *requirementsfakes.FakeFactory
flagContext flags.FlagContext
spaceRequirement *requirementsfakes.FakeSpaceRequirement
domainRequirement *requirementsfakes.FakeDomainRequirement
minAPIVersionRequirement requirements.Requirement
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
routeRepo = new(apifakes.FakeRouteRepository)
repoLocator := deps.RepoLocator.SetRouteRepository(routeRepo)
deps = commandregistry.Dependency{
UI: ui,
示例3:
"github.com/cloudfoundry/cli/cf/api"
"github.com/cloudfoundry/cli/cf/commands/space"
"github.com/cloudfoundry/cli/cf/models"
"github.com/cloudfoundry/cli/cf/requirements"
"github.com/cloudfoundry/cli/cf/requirements/requirementsfakes"
"github.com/cloudfoundry/cli/flags"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("space command", func() {
var (
ui *testterm.FakeUI
loginReq *requirementsfakes.FakeRequirement
targetedOrgReq *requirementsfakes.FakeTargetedOrgRequirement
reqFactory *requirementsfakes.FakeFactory
deps commandregistry.Dependency
cmd space.ShowSpace
flagContext flags.FlagContext
getSpaceModel *plugin_models.GetSpace_Model
spaceRequirement *requirementsfakes.FakeSpaceRequirement
quotaRepo *spacequotasfakes.FakeSpaceQuotaRepository
)
BeforeEach(func() {
ui = new(testterm.FakeUI)
quotaRepo = new(spacequotasfakes.FakeSpaceQuotaRepository)
repoLocator := api.RepositoryLocator{}
repoLocator = repoLocator.SetSpaceQuotaRepository(quotaRepo)
getSpaceModel = new(plugin_models.GetSpace_Model)
deps = commandregistry.Dependency{
UI: ui,
示例4:
callRenameSpace([]string{"foo"})
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires", "arguments"},
))
})
})
Describe("when the user is logged in and has provided an old and new space name", func() {
var space models.Space
BeforeEach(func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedOrgRequirementReturns(new(requirementsfakes.FakeTargetedOrgRequirement))
space = models.Space{}
space.Name = "the-old-space-name"
space.GUID = "the-old-space-guid"
spaceReq := new(requirementsfakes.FakeSpaceRequirement)
spaceReq.GetSpaceReturns(space)
requirementsFactory.NewSpaceRequirementReturns(spaceReq)
})
It("renames a space", func() {
originalSpaceName := configRepo.SpaceFields().Name
callRenameSpace([]string{"the-old-space-name", "my-new-space"})
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Renaming space", "the-old-space-name", "my-new-space", "my-org", "my-user"},
[]string{"OK"},
))
spaceGUID, name := spaceRepo.RenameArgsForCall(0)
Expect(spaceGUID).To(Equal("the-old-space-guid"))