"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."}, )) }) }) }) })
logRepoWithTimeout := new(logsfakes.FakeLogsRepositoryWithTimeout) 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())
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"}))
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" })