Example #1
0
	Context("when logged in", func() {
		var (
			app models.Application
		)

		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true

			app = models.Application{}
			app.Name = "my-app"
			app.Guid = "my-app-guid"

			currentTime := time.Now()
			recentLogs := []*logmessage.LogMessage{
				testlogs.NewLogMessage("Log Line 1", app.Guid, "DEA", currentTime),
				testlogs.NewLogMessage("Log Line 2", app.Guid, "DEA", currentTime),
			}

			appLogs := []*logmessage.LogMessage{
				testlogs.NewLogMessage("Log Line 1", app.Guid, "DEA", time.Now()),
			}

			requirementsFactory.Application = app
			logsRepo.RecentLogsForReturns(recentLogs, nil)

			logsRepo.TailLogsForStub = func(appGuid string, onConnect func(), onMessage func(*logmessage.LogMessage)) error {
				onConnect()
				for _, log := range appLogs {
					onMessage(log)
				}
Example #2
0
		testcmd.RunCommand(cmd, args, requirementsFactory)
		return
	}

	startAppWithInstancesAndErrors := func(displayApp ApplicationDisplayer, app models.Application, requirementsFactory *testreq.FakeReqFactory) (ui *testterm.FakeUI, appRepo *testApplication.FakeApplicationRepository, appInstancesRepo *testAppInstanaces.FakeAppInstancesRepository) {
		configRepo := testconfig.NewRepositoryWithDefaults()
		appRepo = &testApplication.FakeApplicationRepository{
			UpdateAppResult: app,
		}
		appRepo.ReadReturns.App = app
		appInstancesRepo = &testAppInstanaces.FakeAppInstancesRepository{}
		appInstancesRepo.GetInstancesStub = getInstance

		logsForTail = []*logmessage.LogMessage{
			testlogs.NewLogMessage("Log Line 1", app.Guid, LogMessageTypeStaging, time.Now()),
			testlogs.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
	}

	It("fails requirements when not logged in", func() {
		requirementsFactory.LoginSuccess = false
		cmd := NewStart(new(testterm.FakeUI), testconfig.NewRepository(), &testcmd.FakeAppDisplayer{}, &testApplication.FakeApplicationRepository{}, &testAppInstanaces.FakeAppInstancesRepository{}, &testapi.FakeLogsRepository{})
		testcmd.RunCommand(cmd, []string{"some-app-name"}, requirementsFactory)
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())