terminalUI = terminal.NewUI(nil, outputBuffer, nil) fakeTailedLogsOutputter = fake_tailed_logs_outputter.NewFakeTailedLogsOutputter() signalChan = make(chan os.Signal) fakeExitHandler = &fake_exit_handler.FakeExitHandler{} }) Describe("LogsCommand", func() { var logsCommand cli.Command BeforeEach(func() { commandFactory := command_factory.NewLogsCommandFactory(appExaminer, taskExaminer, terminalUI, fakeTailedLogsOutputter, fakeExitHandler) logsCommand = commandFactory.MakeLogsCommand() }) It("tails logs", func() { appExaminer.AppExistsReturns(true, nil) doneChan := test_helpers.AsyncExecuteCommandWithArgs(logsCommand, []string{"my-app-guid"}) Eventually(fakeTailedLogsOutputter.OutputTailedLogsCallCount).Should(Equal(1)) Expect(fakeTailedLogsOutputter.OutputTailedLogsArgsForCall(0)).To(Equal("my-app-guid")) Consistently(doneChan).ShouldNot(BeClosed()) }) It("handles invalid appguids", func() { test_helpers.ExecuteCommandWithArgs(logsCommand, []string{}) Expect(outputBuffer).To(test_helpers.SayIncorrectUsage()) Expect(fakeExitHandler.ExitCalledWith).To(Equal([]int{exit_codes.InvalidSyntax})) })