本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/requirements/requirementsfakes.FakeApplicationRequirement類的典型用法代碼示例。如果您正苦於以下問題:Golang FakeApplicationRequirement類的具體用法?Golang FakeApplicationRequirement怎麽用?Golang FakeApplicationRequirement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FakeApplicationRequirement類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
It("fails requirements when not logged in", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
Expect(runCommand("my-app")).To(BeFalse())
})
It("fails if a space is not targeted", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Failing{Message: "not targeting space"})
Expect(runCommand("my-app")).To(BeFalse())
})
It("fails if a application is not found", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
applicationReq := new(requirementsfakes.FakeApplicationRequirement)
applicationReq.ExecuteReturns(errors.New("no app"))
requirementsFactory.NewApplicationRequirementReturns(applicationReq)
Expect(runCommand("my-app")).To(BeFalse())
})
Describe("Flag options", func() {
var args []string
BeforeEach(func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
})
Context("when an -i flag is provided", func() {
示例2:
testterm "code.cloudfoundry.org/cli/testhelpers/terminal"
"code.cloudfoundry.org/cli/cf/commandregistry"
"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
. "code.cloudfoundry.org/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("restart command", func() {
var (
ui *testterm.FakeUI
requirementsFactory *requirementsfakes.FakeFactory
starter *applicationfakes.FakeStarter
stopper *applicationfakes.FakeStopper
config coreconfig.Repository
app models.Application
originalStop commandregistry.Command
originalStart commandregistry.Command
deps commandregistry.Dependency
applicationReq *requirementsfakes.FakeApplicationRequirement
)
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.Config = config
//inject fake 'stopper and starter' into registry
commandregistry.Register(starter)
commandregistry.Register(stopper)
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("restart").SetDependency(deps, pluginCall))
示例3:
. "code.cloudfoundry.org/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
const TIMESTAMP_FORMAT = "2006-01-02T15:04:05.00-0700"
var _ = Describe("events command", func() {
var (
reqFactory *requirementsfakes.FakeFactory
eventsRepo *appeventsfakes.FakeAppEventsRepository
ui *testterm.FakeUI
config *coreconfigfakes.FakeRepository
deps commandregistry.Dependency
flagContext flags.FlagContext
loginRequirement requirements.Requirement
targetedSpaceRequirement requirements.Requirement
applicationRequirement *requirementsfakes.FakeApplicationRequirement
cmd *application.Events
)
BeforeEach(func() {
cmd = &application.Events{}
ui = new(testterm.FakeUI)
eventsRepo = new(appeventsfakes.FakeAppEventsRepository)
config = new(coreconfigfakes.FakeRepository)
config.OrganizationFieldsReturns(models.OrganizationFields{Name: "my-org"})
示例4:
. "code.cloudfoundry.org/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("UnmapRoute", func() {
var (
ui *testterm.FakeUI
configRepo coreconfig.Repository
routeRepo *apifakes.FakeRouteRepository
cmd commandregistry.Command
deps commandregistry.Dependency
factory *requirementsfakes.FakeFactory
flagContext flags.FlagContext
loginRequirement requirements.Requirement
applicationRequirement *requirementsfakes.FakeApplicationRequirement
domainRequirement *requirementsfakes.FakeDomainRequirement
minAPIVersionRequirement requirements.Requirement
fakeDomain models.DomainFields
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
routeRepo = new(apifakes.FakeRouteRepository)
repoLocator := deps.RepoLocator.SetRouteRepository(routeRepo)
示例5:
. "code.cloudfoundry.org/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("App", func() {
var (
ui *testterm.FakeUI
appSummaryRepo *apifakes.FakeAppSummaryRepository
appInstancesRepo *appinstancesfakes.FakeAppInstancesRepository
stackRepo *stacksfakes.FakeStackRepository
getAppModel *plugin_models.GetAppModel
cmd commandregistry.Command
deps commandregistry.Dependency
factory *requirementsfakes.FakeFactory
flagContext flags.FlagContext
loginRequirement requirements.Requirement
targetedSpaceRequirement requirements.Requirement
applicationRequirement *requirementsfakes.FakeApplicationRequirement
)
BeforeEach(func() {
cmd = &application.ShowApp{}
flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
ui = &testterm.FakeUI{}
getAppModel = &plugin_models.GetAppModel{}
示例6:
cmd.StartupTimeout = 200 * time.Millisecond
cmd.PingerThrottle = 10 * time.Millisecond
commandregistry.Register(cmd)
return testcmd.RunCLICommandWithoutDependency("start", args, requirementsFactory, ui)
}
startAppWithInstancesAndErrors := func(app models.Application, requirementsFactory *requirementsfakes.FakeFactory) (*testterm.FakeUI, *applicationsfakes.FakeRepository, *appinstancesfakes.FakeAppInstancesRepository) {
appRepo.UpdateReturns(app, nil)
appRepo.ReadReturns(app, nil)
appRepo.GetAppReturns(app, nil)
appInstancesRepo.GetInstancesStub = getInstance
args := []string{"my-app"}
applicationReq := new(requirementsfakes.FakeApplicationRequirement)
applicationReq.GetApplicationReturns(app)
requirementsFactory.NewApplicationRequirementReturns(applicationReq)
callStart(args)
return ui, appRepo, appInstancesRepo
}
It("fails requirements when not logged in", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
Expect(callStart([]string{"some-app-name"})).To(BeFalse())
})
It("fails requirements when a space is not targeted", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Failing{Message: "not targeting space"})
示例7:
It("fails if a space is not targeted", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Failing{Message: "not targeting space"})
Expect(runCommand("my-app")).To(BeFalse())
})
})
Describe("getting health_check_type", func() {
BeforeEach(func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
})
Context("when application is not found", func() {
It("Fails", func() {
appRequirement := new(requirementsfakes.FakeApplicationRequirement)
appRequirement.ExecuteReturns(errors.New("no app"))
requirementsFactory.NewApplicationRequirementReturns(appRequirement)
Expect(runCommand("non-exist-app")).To(BeFalse())
})
})
Context("when application exists", func() {
BeforeEach(func() {
app := models.Application{}
app.Name = "my-app"
app.GUID = "my-app-guid"
app.HealthCheckType = "port"
applicationReq := new(requirementsfakes.FakeApplicationRequirement)
applicationReq.GetApplicationReturns(app)