本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/requirements/requirementsfakes.FakeApplicationRequirement類的典型用法代碼示例。如果您正苦於以下問題:Golang FakeApplicationRequirement類的具體用法?Golang FakeApplicationRequirement怎麽用?Golang FakeApplicationRequirement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FakeApplicationRequirement類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
appInstancesRepo = new(appinstancesfakes.FakeAppInstancesRepository)
config = testconfig.NewRepositoryWithDefaults()
requirementsFactory = new(requirementsfakes.FakeFactory)
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
application = models.Application{}
application.Name = "my-app"
application.GUID = "my-app-guid"
application.InstanceCount = 1
applicationReq := new(requirementsfakes.FakeApplicationRequirement)
applicationReq.GetApplicationReturns(application)
requirementsFactory.NewApplicationRequirementReturns(applicationReq)
})
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.Config = config
deps.RepoLocator = deps.RepoLocator.SetAppInstancesRepository(appInstancesRepo)
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("restart-app-instance").SetDependency(deps, pluginCall))
}
runCommand := func(args ...string) bool {
return testcmd.RunCLICommand("restart-app-instance", args, requirementsFactory, updateCommandDependency, false, ui)
}
示例2:
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() {
示例3:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("MapRoute", 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
diegoApplicationRequirement *requirementsfakes.FakeDiegoApplicationRequirement
originalCreateRouteCmd commandregistry.Command
fakeCreateRouteCmd commandregistry.Command
fakeDomain models.DomainFields
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
routeRepo = new(apifakes.FakeRouteRepository)
示例4:
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)
示例5:
. "github.com/cloudfoundry/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"})
示例6:
. "github.com/cloudfoundry/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
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{}
示例7:
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"})