本文整理汇总了Golang中testhelpers/requirements.FakeReqFactory.Application方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeReqFactory.Application方法的具体用法?Golang FakeReqFactory.Application怎么用?Golang FakeReqFactory.Application使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testhelpers/requirements.FakeReqFactory
的用法示例。
在下文中一共展示了FakeReqFactory.Application方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: startAppWithInstancesAndErrors
func startAppWithInstancesAndErrors(displayApp ApplicationDisplayer, app models.Application, instances [][]models.AppInstanceFields, errorCodes []string, requirementsFactory *testreq.FakeReqFactory) (ui *testterm.FakeUI, appRepo *testapi.FakeApplicationRepository, appInstancesRepo *testapi.FakeAppInstancesRepo) {
configRepo := testconfig.NewRepositoryWithDefaults()
appRepo = &testapi.FakeApplicationRepository{
UpdateAppResult: app,
}
appRepo.ReadReturns.App = app
appInstancesRepo = &testapi.FakeAppInstancesRepo{
GetInstancesResponses: instances,
GetInstancesErrorCodes: errorCodes,
}
logRepo := &testapi.FakeLogsRepository{
TailLogMessages: []*logmessage.Message{
NewLogMessage("Log Line 1", app.Guid, LogMessageTypeStaging, time.Now()),
NewLogMessage("Log Line 2", app.Guid, LogMessageTypeStaging, time.Now()),
},
}
args := []string{"my-app"}
requirementsFactory.Application = app
ui = callStart(args, configRepo, requirementsFactory, displayApp, appRepo, appInstancesRepo, logRepo)
return
}
示例2:
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
})
Context("when logged in", func() {
BeforeEach(func() {
requirementsFactory.LoginSuccess = true
})
It("binds a service instance to an app", func() {
app := models.Application{}
app.Name = "my-app"
app.Guid = "my-app-guid"
serviceInstance := models.ServiceInstance{}
serviceInstance.Name = "my-service"
serviceInstance.Guid = "my-service-guid"
requirementsFactory.Application = app
requirementsFactory.ServiceInstance = serviceInstance
serviceBindingRepo := &testapi.FakeServiceBindingRepo{}
ui := callBindService([]string{"my-app", "my-service"}, requirementsFactory, serviceBindingRepo)
Expect(requirementsFactory.ApplicationName).To(Equal("my-app"))
Expect(requirementsFactory.ServiceInstanceName).To(Equal("my-service"))
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Binding service", "my-service", "my-app", "my-org", "my-space", "my-user"},
{"OK"},
{"TIP"},
})
Expect(serviceBindingRepo.CreateServiceInstanceGuid).To(Equal("my-service-guid"))
Expect(serviceBindingRepo.CreateApplicationGuid).To(Equal("my-app-guid"))
})
示例3:
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"my-app", "my-org", "my-space", "my-user"},
{"OK"},
{"0 of 2 instances running", "2 starting"},
{"Started"},
})
Expect(requirementsFactory.ApplicationName).To(Equal("my-app"))
Expect(appRepo.UpdateAppGuid).To(Equal("my-app-guid"))
Expect(displayApp.AppToDisplay).To(Equal(defaultAppForStart))
})
It("only displays staging logs when an app is starting", func() {
displayApp := &testcmd.FakeAppDisplayer{}
requirementsFactory.Application = defaultAppForStart
appRepo := &testapi.FakeApplicationRepository{
UpdateAppResult: defaultAppForStart,
}
appRepo.ReadReturns.App = defaultAppForStart
appInstancesRepo := &testapi.FakeAppInstancesRepo{
GetInstancesResponses: defaultInstanceReponses,
GetInstancesErrorCodes: defaultInstanceErrorCodes,
}
currentTime := time.Now()
wrongSourceName := "DEA"
correctSourceName := "STG"
logRepo := &testapi.FakeLogsRepository{
示例4:
runCommand()
Expect(ui.FailedWithUsage).To(BeTrue())
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
})
It("lists events given an app name", func() {
earlierTimestamp, err := time.Parse(TIMESTAMP_FORMAT, "1999-12-31T23:59:11.00-0000")
Expect(err).NotTo(HaveOccurred())
timestamp, err := time.Parse(TIMESTAMP_FORMAT, "2000-01-01T00:01:11.00-0000")
Expect(err).NotTo(HaveOccurred())
app := models.Application{}
app.Name = "my-app"
app.Guid = "my-app-guid"
reqFactory.Application = app
eventsRepo.RecentEventsReturns.Events = []models.EventFields{
{
Guid: "event-guid-1",
Name: "app crashed",
Timestamp: earlierTimestamp,
Description: "reason: app instance exited, exit_status: 78",
},
{
Guid: "event-guid-2",
Name: "app crashed",
Timestamp: timestamp,
Description: "reason: app instance was stopped, exit_status: 77",
},
}