本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/requirements/requirementsfakes.FakeApplicationRequirement.GetApplicationReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeApplicationRequirement.GetApplicationReturns方法的具體用法?Golang FakeApplicationRequirement.GetApplicationReturns怎麽用?Golang FakeApplicationRequirement.GetApplicationReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/cloudfoundry/org/cli/cf/requirements/requirementsfakes.FakeApplicationRequirement
的用法示例。
在下文中一共展示了FakeApplicationRequirement.GetApplicationReturns方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
deps = commandregistry.NewDependency(os.Stdout, new(tracefakes.FakePrinter), "")
requirementsFactory = new(requirementsfakes.FakeFactory)
starter = new(applicationfakes.FakeStarter)
stopper = new(applicationfakes.FakeStopper)
config = testconfig.NewRepositoryWithDefaults()
app = models.Application{}
app.Name = "my-app"
app.GUID = "my-app-guid"
applicationReq = new(requirementsfakes.FakeApplicationRequirement)
applicationReq.GetApplicationReturns(app)
//save original command and restore later
originalStart = commandregistry.Commands.FindCommand("start")
originalStop = commandregistry.Commands.FindCommand("stop")
//setup fakes to correctly interact with commandregistry
starter.SetDependencyStub = func(_ commandregistry.Dependency, _ bool) commandregistry.Command {
return starter
}
starter.MetaDataReturns(commandregistry.CommandMetadata{Name: "start"})
stopper.SetDependencyStub = func(_ commandregistry.Dependency, _ bool) commandregistry.Command {
return stopper
}
stopper.MetaDataReturns(commandregistry.CommandMetadata{Name: "stop"})
示例2:
var (
currentApp models.Application
)
BeforeEach(func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
currentApp = models.Application{}
currentApp.Name = "my-app"
currentApp.State = "started"
currentApp.GUID = "my-app-guid"
currentApp.EnableSSH = true
currentApp.Diego = true
applicationReq := new(requirementsfakes.FakeApplicationRequirement)
applicationReq.GetApplicationReturns(currentApp)
requirementsFactory.NewApplicationRequirementReturns(applicationReq)
})
Describe("Error getting required info to run ssh", func() {
var (
testServer *httptest.Server
handler *testnet.TestHandler
)
AfterEach(func() {
testServer.Close()
})
Context("error when getting SSH info from /v2/info", func() {
BeforeEach(func() {
示例3:
})
It("returns a ApplicationRequirement", func() {
Expect(reqFactory.NewApplicationRequirementCallCount()).To(Equal(1))
Expect(actualRequirements).To(ContainElement(applicationRequirement))
})
})
})
Describe("Execute", func() {
var executeCmdErr error
BeforeEach(func() {
applicationRequirement.GetApplicationReturns(models.Application{
ApplicationFields: models.ApplicationFields{
Name: "my-app",
GUID: "my-app-guid",
},
})
err := flagContext.Parse("my-app")
Expect(err).NotTo(HaveOccurred())
})
JustBeforeEach(func() {
executeCmdErr = cmd.Execute(flagContext)
})
Context("when no events exist", func() {
BeforeEach(func() {
eventsRepo.RecentEventsReturns([]models.EventFields{}, nil)
示例4:
cmd = &route.UnmapRoute{}
cmd.SetDependency(deps, false)
flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
factory = new(requirementsfakes.FakeFactory)
loginRequirement = &passingRequirement{Name: "login-requirement"}
factory.NewLoginRequirementReturns(loginRequirement)
applicationRequirement = new(requirementsfakes.FakeApplicationRequirement)
factory.NewApplicationRequirementReturns(applicationRequirement)
fakeApplication := models.Application{}
fakeApplication.GUID = "fake-app-guid"
applicationRequirement.GetApplicationReturns(fakeApplication)
domainRequirement = new(requirementsfakes.FakeDomainRequirement)
factory.NewDomainRequirementReturns(domainRequirement)
fakeDomain = models.DomainFields{
GUID: "fake-domain-guid",
Name: "fake-domain-name",
}
domainRequirement.GetDomainReturns(fakeDomain)
minAPIVersionRequirement = &passingRequirement{Name: "min-api-version-requirement"}
factory.NewMinAPIVersionRequirementReturns(minAPIVersionRequirement)
})
Describe("Help text", func() {
示例5:
Details: "fake-instance-details",
Since: time.Date(2015, time.November, 19, 1, 1, 17, 0, time.UTC),
CPUUsage: float64(0.25),
DiskUsage: int64(1 * formatters.GIGABYTE),
DiskQuota: int64(2 * formatters.GIGABYTE),
MemUsage: int64(24 * formatters.MEGABYTE),
MemQuota: int64(32 * formatters.MEGABYTE),
},
}
appStackModel = models.Stack{
GUID: "fake-stack-guid",
Name: "fake-stack-name",
}
applicationRequirement.GetApplicationReturns(getApplicationModel)
appSummaryRepo.GetSummaryReturns(getAppSummaryModel, getAppSummaryErr)
appInstancesRepo.GetInstancesReturns(appInstanceFields, nil)
stackRepo.FindByGUIDReturns(appStackModel, nil)
})
JustBeforeEach(func() {
err = cmd.Execute(flagContext)
})
It("gets the application summary", func() {
Expect(err).NotTo(HaveOccurred())
Expect(appSummaryRepo.GetSummaryCallCount()).To(Equal(1))
})
It("gets the app instances", func() {
示例6:
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"})