Example #1
0
			})
		})
	})

	Describe("ContainerMetrics", func() {
		var (
			appGuid                  = "appGuid"
			authToken                = "authToken"
			receivedContainerMetrics []*events.ContainerMetric
			recentError              error
		)

		perform := func() {
			close(messagesToSend)
			connection = noaa.NewConsumer(trafficControllerUrl, nil, nil)
			receivedContainerMetrics, recentError = connection.ContainerMetrics(appGuid, authToken)
		}

		Context("when the connection cannot be established", func() {
			It("invalid urls return error", func() {
				trafficControllerUrl = "invalid-url"
				perform()

				Expect(recentError).ToNot(BeNil())
			})
		})

		Context("when the connection can be established", func() {
			BeforeEach(func() {
				testServer = httptest.NewServer(handlers.NewHttpHandler(messagesToSend, loggertesthelper.Logger()))
				trafficControllerUrl = "ws://" + testServer.Listener.Addr().String()
Example #2
0
			})
		})
	})

	Describe("ContainerMetrics", func() {
		var (
			appGuid                  = "appGuid"
			authToken                = "authToken"
			receivedContainerMetrics []*events.ContainerMetric
			recentError              error
		)

		perform := func() {
			close(messagesToSend)
			cnsmr = noaa.NewConsumer(trafficControllerUrl, nil, nil)
			receivedContainerMetrics, recentError = cnsmr.ContainerMetrics(appGuid, authToken)
		}

		Context("when the connection cannot be established", func() {
			It("invalid urls return error", func() {
				trafficControllerUrl = "invalid-url"
				perform()

				Expect(recentError).ToNot(BeNil())
			})
		})

		Context("when the connection can be established", func() {
			BeforeEach(func() {
				testServer = httptest.NewServer(handlers.NewHttpHandler(messagesToSend, loggertesthelper.Logger()))
				trafficControllerUrl = "ws://" + testServer.Listener.Addr().String()