It("emits the time it took to stage succesfully", func() { Expect(metricSender.GetValue("StagingRequestSucceededDuration")).To(Equal(fake.Metric{ Value: float64(stagingDurationNano), Unit: "nanos", })) }) It("returns a 200", func() { Expect(responseRecorder.Code).To(Equal(200)) }) }) Context("when the CC request fails", func() { BeforeEach(func() { fakeCCClient.StagingCompleteReturns(&cc_client.BadResponseError{504}) }) It("responds with the status code that the CC returned", func() { Expect(responseRecorder.Code).To(Equal(504)) }) }) Context("When an error occurs in making the CC request", func() { BeforeEach(func() { fakeCCClient.StagingCompleteReturns(errors.New("whoops")) }) It("responds with a 503 error", func() { Expect(responseRecorder.Code).To(Equal(503)) })