)

var _ = Describe("NozzlePlugin", func() {
	Describe(".Run", func() {
		var fakeCliConnection *pluginfakes.FakeCliConnection
		var nozzlerCmd *NozzlerCmd
		var fakeFirehose *testhelpers.FakeFirehose

		BeforeEach(func() {
			fakeFirehose = testhelpers.NewFakeFirehose(ACCESS_TOKEN)
			fakeFirehose.SendEvent(events.Envelope_LogMessage, "Log Message")
			fakeFirehose.Start()

			fakeCliConnection = &pluginfakes.FakeCliConnection{}
			fakeCliConnection.AccessTokenReturns(ACCESS_TOKEN, nil)
			fakeCliConnection.DopplerEndpointReturns(fakeFirehose.URL(), nil)
			nozzlerCmd = &NozzlerCmd{}
		})

		AfterEach(func() {
			fakeFirehose.Close()
		})

		Context("when invoked via 'app-nozzle'", func() {
			Context("when app name is not recognized", func() {
				BeforeEach(func() {
					fakeCliConnection.GetAppReturns(plugin_models.GetAppModel{}, errors.New("App not found"))
				})
				It("returns error message", func(done Done) {
					defer close(done)
					outputChan := make(chan []string)
Пример #2
0
				var fakeFirehose *testhelpers.FakeFirehose
				BeforeEach(func() {
					fakeFirehose = testhelpers.NewFakeFirehoseInAppMode("ACCESS_TOKEN", "spring-music")
					fakeFirehose.SendEvent(events.Envelope_LogMessage, "This is a very special test message")
					fakeFirehose.SendEvent(events.Envelope_ValueMetric, "valuemetric")
					fakeFirehose.SendEvent(events.Envelope_CounterEvent, "counterevent")
					fakeFirehose.SendEvent(events.Envelope_ContainerMetric, "containermetric")
					fakeFirehose.SendEvent(events.Envelope_Error, "this is an error")
					fakeFirehose.SendEvent(events.Envelope_HttpStart, "start request")
					fakeFirehose.SendEvent(events.Envelope_HttpStop, "stop request")
					fakeFirehose.SendEvent(events.Envelope_HttpStartStop, "startstop request")
					fakeFirehose.Start()
				})
				It("prints out debug information if demanded", func() {
					options.Debug = true
					client := firehose.NewClient("ACCESS_TOKEN", fakeFirehose.URL(), options, ui)
					client.Start()
					Expect(stdout).To(ContainSubstring("WEBSOCKET REQUEST"))
					Expect(stdout).To(ContainSubstring("WEBSOCKET RESPONSE"))
				})
				It("shows no debug output if not requested", func() {
					options.Debug = false
					client := firehose.NewClient("ACCESS_TOKEN", fakeFirehose.URL(), options, 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(), options, ui)
					client.Start()
					Expect(stdout).To(ContainSubstring("This is a very special test message"))