本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/api/applications/fakes.FakeApplicationRepository.ReadReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeApplicationRepository.ReadReturns方法的具體用法?Golang FakeApplicationRepository.ReadReturns怎麽用?Golang FakeApplicationRepository.ReadReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/cli/cf/api/applications/fakes.FakeApplicationRepository
的用法示例。
在下文中一共展示了FakeApplicationRepository.ReadReturns方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
appName = "fake-app-name"
ui = &testterm.FakeUI{}
appRepo = &testApplication.FakeApplicationRepository{}
req = requirements.NewDEAApplicationRequirement(appName, ui, appRepo)
})
Describe("GetApplication", func() {
It("returns an empty application", func() {
Expect(req.GetApplication()).To(Equal(models.Application{}))
})
Context("when the requirement has been executed", func() {
BeforeEach(func() {
app := models.Application{}
app.Guid = "fake-app-guid"
appRepo.ReadReturns(app, nil)
req.Execute()
})
It("returns the application", func() {
Expect(req.GetApplication().Guid).To(Equal("fake-app-guid"))
})
})
})
Describe("Execute", func() {
Context("when the returned application is a Diego application", func() {
BeforeEach(func() {
app := models.Application{}
app.Diego = true
示例2:
cmd := command_registry.Commands.FindCommand("start").(*Start)
cmd.LogServerConnectionTimeout = 100 * time.Millisecond
cmd.StagingTimeout = 100 * time.Millisecond
cmd.StartupTimeout = 200 * time.Millisecond
cmd.PingerThrottle = 50 * time.Millisecond
command_registry.Register(cmd)
testcmd.RunCliCommandWithoutDependency("start", args, requirementsFactory)
return
}
startAppWithInstancesAndErrors := func(displayApp ApplicationDisplayer, app models.Application, requirementsFactory *testreq.FakeReqFactory) (*testterm.FakeUI, *testApplication.FakeApplicationRepository, *testAppInstanaces.FakeAppInstancesRepository) {
appRepo = &testApplication.FakeApplicationRepository{}
appRepo.UpdateReturns(app, nil)
appRepo.ReadReturns(app, nil)
appRepo.GetAppReturns(app, nil)
appInstancesRepo = &testAppInstanaces.FakeAppInstancesRepository{}
appInstancesRepo.GetInstancesStub = getInstance
args := []string{"my-app"}
requirementsFactory.Application = app
callStart(args)
return ui, appRepo, appInstancesRepo
}
It("fails requirements when not logged in", func() {
requirementsFactory.LoginSuccess = false
Expect(callStart([]string{"some-app-name"})).To(BeFalse())
示例3:
It("fails when a space is not targeted", func() {
requirementsFactory.TargetedSpaceSuccess = false
Expect(callPush()).To(BeFalse())
})
// yes, we're aware that the args here should probably be provided in a different order
// erg: app-name -p some/path some-extra-arg
// but the test infrastructure for parsing args and flags is sorely lacking
It("fails when provided too many args", func() {
Expect(callPush("-p", "path", "too-much", "app-name")).To(BeFalse())
})
})
Describe("when pushing a new app", func() {
BeforeEach(func() {
appRepo.ReadReturns(models.Application{}, errors.NewModelNotFoundError("App", "the-app"))
appRepo.CreateStub = func(params models.AppParams) (models.Application, error) {
a := models.Application{}
a.Guid = *params.Name + "-guid"
a.Name = *params.Name
a.State = "stopped"
return a, nil
}
zipper.ZipReturns(nil)
zipper.GetZipSizeReturns(9001, nil)
actor.GatherFilesReturns(nil, true, nil)
actor.UploadAppReturns(nil)
})
示例4:
Context("when logged in", func() {
BeforeEach(func() {
requirementsFactory.LoginSuccess = true
requirementsFactory.TargetedSpaceSuccess = true
})
It("fails with usage when not provided exactly one arg", func() {
runCommand()
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires", "argument"},
))
})
Context("When provided an app that exists", func() {
BeforeEach(func() {
appRepo.ReadReturns(app, nil)
})
It("deletes an app when the user confirms", func() {
ui.Inputs = []string{"y"}
runCommand("app-to-delete")
Expect(appRepo.ReadArgsForCall(0)).To(Equal("app-to-delete"))
Expect(appRepo.DeleteArgsForCall(0)).To(Equal("app-to-delete-guid"))
Expect(ui.Prompts).To(ContainSubstrings([]string{"Really delete the app app-to-delete"}))
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Deleting", "app-to-delete", "my-org", "my-space", "my-user"},
[]string{"OK"},
示例5:
)
var _ = Describe("ApplicationRequirement", func() {
var ui *testterm.FakeUI
var appRepo *testApplication.FakeApplicationRepository
BeforeEach(func() {
ui = new(testterm.FakeUI)
appRepo = &testApplication.FakeApplicationRepository{}
})
It("succeeds when an app with the given name exists", func() {
app := models.Application{}
app.Name = "my-app"
app.Guid = "my-app-guid"
appRepo.ReadReturns(app, nil)
appReq := NewApplicationRequirement("foo", ui, appRepo)
Expect(appReq.Execute()).To(BeTrue())
Expect(appRepo.ReadArgsForCall(0)).To(Equal("foo"))
Expect(appReq.GetApplication()).To(Equal(app))
})
It("fails when an app with the given name cannot be found", func() {
appRepo.ReadReturns(models.Application{}, errors.NewModelNotFoundError("app", "foo"))
testassert.AssertPanic(testterm.QuietPanic, func() {
NewApplicationRequirement("foo", ui, appRepo).Execute()
})
})
示例6:
[]string{"Removing env variable", "DATABASE_URL", "my-app", "my-org", "my-space", "my-user"},
[]string{"OK"},
))
Expect(requirementsFactory.ApplicationName).To(Equal("my-app"))
appGUID, params := appRepo.UpdateArgsForCall(0)
Expect(appGUID).To(Equal("my-app-guid"))
Expect(*params.EnvironmentVars).To(Equal(map[string]interface{}{
"foo": "bar",
}))
})
Context("when updating the app fails", func() {
BeforeEach(func() {
appRepo.UpdateReturns(models.Application{}, errors.New("Error updating app."))
appRepo.ReadReturns(app, nil)
})
It("fails and alerts the user", func() {
runCommand("does-not-exist", "DATABASE_URL")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Removing env variable"},
[]string{"FAILED"},
[]string{"Error updating app."},
))
})
})
It("tells the user if the specified env var was not set", func() {
runCommand("my-app", "CANT_STOP_WONT_STOP_UNSETTIN_THIS_ENV")
示例7:
})
})
Describe("when retrieving the app token succeeds", func() {
var (
sourceApp, targetApp models.Application
)
BeforeEach(func() {
sourceApp = models.Application{
ApplicationFields: models.ApplicationFields{
Name: "source-app",
Guid: "source-app-guid",
},
}
appRepo.ReadReturns(sourceApp, nil)
targetApp = models.Application{
ApplicationFields: models.ApplicationFields{
Name: "target-app",
Guid: "target-app-guid",
},
}
appRepo.ReadFromSpaceReturns(targetApp, nil)
})
Describe("when no parameters are passed", func() {
It("obtains both the source and target application from the same space", func() {
runCommand("source-app", "target-app")
targetAppName, spaceGuid := appRepo.ReadFromSpaceArgsForCall(0)