recentLogs := []logs.Loggable{ testlogs.NewLogMessage("Log Line 1", app.GUID, "DEA", "1", logmessage.LogMessage_ERR, currentTime), testlogs.NewLogMessage("Log Line 2", app.GUID, "DEA", "1", logmessage.LogMessage_ERR, currentTime), } appLogs := []logs.Loggable{ testlogs.NewLogMessage("Log Line 1", app.GUID, "DEA", "1", logmessage.LogMessage_ERR, time.Now()), } requirementsFactory.Application = app logsRepo.RecentLogsForReturns(recentLogs, nil) logsRepo.TailLogsForStub = func(appGUID string, onConnect func(), logChan chan<- logs.Loggable, errChan chan<- error) { onConnect() go func() { for _, log := range appLogs { logChan <- log } close(logChan) close(errChan) }() } }) It("shows the recent logs when the --recent flag is provided", func() { runCommand("--recent", "my-app") Expect(requirementsFactory.ApplicationName).To(Equal("my-app")) Expect(app.GUID).To(Equal(logsRepo.RecentLogsForArgsForCall(0))) Expect(ui.Outputs).To(ContainSubstrings( []string{"Connected, dumping recent logs for app", "my-app", "my-org", "my-space", "my-user"}, []string{"Log Line 1"}, []string{"Log Line 2"},
{instance1, instance2}, {instance3, instance4}, } logRepo = new(logsfakes.FakeLogsRepository) logMessages = []logs.Loggable{} closeWait := sync.WaitGroup{} closeWait.Add(1) logRepo.TailLogsForStub = func(appGUID string, onConnect func(), logChan chan<- logs.Loggable, errChan chan<- error) { onConnect() go func() { for _, log := range logMessages { logChan <- log } closeWait.Wait() close(logChan) }() } logRepo.CloseStub = func() { closeWait.Done() } }) callStart := func(args []string) bool { updateCommandDependency(logRepo) cmd := commandregistry.Commands.FindCommand("start").(*Start) cmd.StagingTimeout = 100 * time.Millisecond