本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/api/applications/applicationsfakes.FakeApplicationRepository.ReadReturns方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeApplicationRepository.ReadReturns方法的具体用法?Golang FakeApplicationRepository.ReadReturns怎么用?Golang FakeApplicationRepository.ReadReturns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/api/applications/applicationsfakes.FakeApplicationRepository
的用法示例。
在下文中一共展示了FakeApplicationRepository.ReadReturns方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
)
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.Config = configRepo
deps.RepoLocator = deps.RepoLocator.SetApplicationRepository(appRepo)
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("env").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
app = models.Application{}
app.Name = "my-app"
appRepo = new(applicationsfakes.FakeApplicationRepository)
appRepo.ReadReturns(app, nil)
configRepo = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
})
runCommand := func(args ...string) bool {
return testcmd.RunCLICommand("env", args, requirementsFactory, updateCommandDependency, false)
}
Describe("Requirements", func() {
It("fails when the user is not logged in", func() {
requirementsFactory.LoginSuccess = false
Expect(runCommand("my-app")).To(BeFalse())
})
It("fails if a space is not targeted", func() {
示例2:
appName = "fake-app-name"
appRepo = new(applicationsfakes.FakeApplicationRepository)
req = requirements.NewDiegoApplicationRequirement(appName, 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.Diego = true
app.GUID = "fake-app-guid"
appRepo.ReadReturns(app, nil)
Expect(req.Execute()).ToNot(HaveOccurred())
})
It("returns the application", func() {
Expect(req.GetApplication().GUID).To(Equal("fake-app-guid"))
})
})
})
Describe("Execute", func() {
Context("when the returned application is a DEA application", func() {
BeforeEach(func() {
app := models.Application{}
app.Diego = false
示例3:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("ApplicationRequirement", func() {
var appRepo *applicationsfakes.FakeApplicationRepository
BeforeEach(func() {
appRepo = new(applicationsfakes.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", appRepo)
err := appReq.Execute()
Expect(err).NotTo(HaveOccurred())
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() {
appError := errors.NewModelNotFoundError("app", "foo")
appRepo.ReadReturns(models.Application{}, appError)
err := NewApplicationRequirement("foo", appRepo).Execute()
示例4:
updateCommandDependency(logRepoWithTimeout)
cmd := commandregistry.Commands.FindCommand("start").(*Start)
cmd.LogServerConnectionTimeout = 100 * time.Millisecond
cmd.StagingTimeout = 100 * time.Millisecond
cmd.StartupTimeout = 200 * time.Millisecond
cmd.PingerThrottle = 10 * time.Millisecond
commandregistry.Register(cmd)
testcmd.RunCLICommandWithoutDependency("start", args, requirementsFactory)
return
}
startAppWithInstancesAndErrors := func(app models.Application, requirementsFactory *testreq.FakeReqFactory) (*testterm.FakeUI, *applicationsfakes.FakeApplicationRepository, *appinstancesfakes.FakeAppInstancesRepository) {
appRepo.UpdateReturns(app, nil)
appRepo.ReadReturns(app, nil)
appRepo.GetAppReturns(app, nil)
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())
})
示例5:
[]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")
示例6:
})
})
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)
示例7:
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"},