本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/api/applications/fakes.FakeApplicationRepository.UpdateReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeApplicationRepository.UpdateReturns方法的具體用法?Golang FakeApplicationRepository.UpdateReturns怎麽用?Golang FakeApplicationRepository.UpdateReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/cli/cf/api/applications/fakes.FakeApplicationRepository
的用法示例。
在下文中一共展示了FakeApplicationRepository.UpdateReturns方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
updateCommandDependency(logRepoWithTimeout)
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
示例2:
Describe("re-pushing an existing app", func() {
var existingApp models.Application
BeforeEach(func() {
existingApp = models.Application{}
existingApp.Name = "existing-app"
existingApp.Guid = "existing-app-guid"
existingApp.Command = "unicorn -c config/unicorn.rb -D"
existingApp.EnvironmentVars = map[string]interface{}{
"crazy": "pants",
"FOO": "NotYoBaz",
"foo": "manchu",
}
appRepo.ReadReturns(existingApp, nil)
appRepo.UpdateReturns(existingApp, nil)
})
It("resets the app's buildpack when the -b flag is provided as 'default'", func() {
callPush("-b", "default", "existing-app")
_, params := appRepo.UpdateArgsForCall(0)
Expect(*params.BuildpackUrl).To(Equal(""))
})
It("resets the app's command when the -c flag is provided as 'default'", func() {
callPush("-c", "default", "existing-app")
_, params := appRepo.UpdateArgsForCall(0)
Expect(*params.Command).To(Equal(""))
})
It("resets the app's buildpack when the -b flag is provided as 'null'", func() {
示例3:
It("stops the app with the given name", func() {
runCommand("my-app")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Stopping app", "my-app", "my-org", "my-space", "my-user"},
[]string{"OK"},
))
Expect(requirementsFactory.ApplicationName).To(Equal("my-app"))
appGUID, _ := appRepo.UpdateArgsForCall(0)
Expect(appGUID).To(Equal("my-app-guid"))
})
It("warns the user when stopping the app fails", func() {
appRepo.UpdateReturns(models.Application{}, errors.New("Error updating app."))
runCommand("my-app")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Stopping", "my-app"},
[]string{"FAILED"},
[]string{"Error updating app."},
))
appGUID, _ := appRepo.UpdateArgsForCall(0)
Expect(appGUID).To(Equal("my-app-guid"))
})
Context("when the app is stopped", func() {
BeforeEach(func() {
app.State = "stopped"
})
示例4:
"MY_VAR",
"--has-a-cool-value",
},
[]string{"OK"},
[]string{"TIP"},
))
_, params := appRepo.UpdateArgsForCall(0)
Expect(*params.EnvironmentVars).To(Equal(map[string]interface{}{
"MY_VAR": "--has-a-cool-value",
"foo": "bar",
}))
})
Context("when setting fails", func() {
BeforeEach(func() {
appRepo.UpdateReturns(models.Application{}, errors.New("Error updating app."))
})
It("tells the user", func() {
runCommand("please", "dont", "fail")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Setting env variable"},
[]string{"FAILED"},
[]string{"Error updating app."},
))
})
})
})
})
示例5:
requirementsFactory.LoginSuccess = true
requirementsFactory.TargetedSpaceSuccess = true
Expect(testcmd.RunCliCommand("scale", []string{"my-app"}, requirementsFactory, updateCommandDependency, false)).To(BeTrue())
})
})
Describe("scaling an app", func() {
BeforeEach(func() {
app = maker.NewApp(maker.Overrides{"name": "my-app", "guid": "my-app-guid"})
app.InstanceCount = 42
app.DiskQuota = 1024
app.Memory = 256
requirementsFactory.Application = app
appRepo.UpdateReturns(app, nil)
})
Context("when no flags are specified", func() {
It("prints a description of the app's limits", func() {
testcmd.RunCliCommand("scale", []string{"my-app"}, requirementsFactory, updateCommandDependency, false)
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Showing", "my-app", "my-org", "my-space", "my-user"},
[]string{"OK"},
[]string{"memory", "256M"},
[]string{"disk", "1G"},
[]string{"instances", "42"},
))
Expect(ui.Outputs).ToNot(ContainSubstrings([]string{"Scaling", "my-app", "my-org", "my-space", "my-user"}))