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}))
		})

		It("handles non existent application", func() {
			appExaminer.AppExistsReturns(false, nil)
			taskExaminer.TaskStatusReturns(task_examiner.TaskInfo{}, errors.New("task not found"))

			doneChan := test_helpers.AsyncExecuteCommandWithArgs(logsCommand, []string{"non_existent_app"})

			Eventually(fakeTailedLogsOutputter.OutputTailedLogsCallCount).Should(Equal(1))
			Expect(fakeTailedLogsOutputter.OutputTailedLogsArgsForCall(0)).To(Equal("non_existent_app"))

			Eventually(outputBuffer).Should(test_helpers.SayLine("Application or task non_existent_app not found."))
			Eventually(outputBuffer).Should(test_helpers.SayLine("Tailing logs and waiting for non_existent_app to appear..."))
Esempio n. 2
0
			Eventually(session, 3).Should(gexec.Exit(0))
			Expect(session.Out).To(gbytes.Say("Target:"))
			Expect(session.Out).To(gbytes.Say(fmt.Sprintf("%s.xip.io:%s", listenerHost, listenerPort)))
		})

		Context("when an unknown command is invoked", func() {
			It("should exit non-zero when an unknown command is invoked", func() {
				command := ltcCommand("unknown-command")

				session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
				Expect(err).NotTo(HaveOccurred())

				Eventually(session, 3).Should(gexec.Exit(1))
				Expect(session.Out).To(gbytes.Say("not a registered command"))
			})
		})

		Context("when a known command is invoked with an invalid flag", func() {
			It("should exit non-zero and print incorrect usage", func() {
				command := ltcCommand("status", "--badFlag")

				session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
				Expect(err).NotTo(HaveOccurred())

				Eventually(session, 3).Should(gexec.Exit(1))
				Expect(session.Out).To(test_helpers.SayIncorrectUsage())
			})
		})
	})
})