It("shows a meaningful error", func() { client := firehose.NewClient("invalidToken", "badEndpoint", false, ui) client.Start() Expect(stdout).To(ContainSubstring("Error dialing traffic controller server")) }) }) Context("when the connection to doppler works", func() { var fakeFirehose *testhelpers.FakeFirehose BeforeEach(func() { fakeFirehose = testhelpers.NewFakeFirehose("ACCESS_TOKEN") fakeFirehose.SendLog("This is a very special test message") fakeFirehose.Start() }) It("prints out debug information if demanded", func() { client := firehose.NewClient("ACCESS_TOKEN", fakeFirehose.URL(), true, ui) client.Start() Expect(stdout).To(ContainSubstring("WEBSOCKET REQUEST")) Expect(stdout).To(ContainSubstring("WEBSOCKET RESPONSE")) }) It("shows no debug output if not requested", func() { client := firehose.NewClient("ACCESS_TOKEN", fakeFirehose.URL(), false, ui) client.Start() Expect(stdout).ToNot(ContainSubstring("WEBSOCKET REQUEST")) Expect(stdout).ToNot(ContainSubstring("WEBSOCKET RESPONSE")) }) It("prints out log messages to the terminal", func() { client := firehose.NewClient("ACCESS_TOKEN", fakeFirehose.URL(), false, ui) client.Start() Expect(stdout).To(ContainSubstring("This is a very special test message")) })
) var _ = Describe("NozzlePlugin", func() { Describe(".Run", func() { var fakeCliConnection *fakes.FakeCliConnection var nozzlerCmd *NozzlerCmd var fakeFirehose *testhelpers.FakeFirehose BeforeEach(func() { fakeFirehose = testhelpers.NewFakeFirehose(ACCESS_TOKEN) fakeFirehose.SendLog("Log Message") fakeFirehose.Start() fakeCliConnection = &fakes.FakeCliConnection{} fakeCliConnection.AccessTokenReturns(ACCESS_TOKEN, nil) fakeCliConnection.DopplerEndpointReturns(fakeFirehose.URL(), nil) nozzlerCmd = &NozzlerCmd{} }) AfterEach(func() { fakeFirehose.Close() }) It("works", func(done Done) { defer close(done) outputChan := make(chan []string) go func() { output := io_helpers.CaptureOutput(func() { nozzlerCmd.Run(fakeCliConnection, []string{"nozzle", "--debug"}) }) outputChan <- output