예제 #1
0
		Context("when the bbs fails", func() {
			BeforeEach(func() {
				fakeBBS.DesireLRPReturns(errors.New("oh no"))
			})

			It("responds with a ServiceUnavailabe error", func() {
				Expect(responseRecorder.Code).To(Equal(http.StatusServiceUnavailable))
			})
		})

		Context("when the bbs fails with a Conflict error", func() {
			BeforeEach(func() {
				fakeBBS.DesireLRPStub = func(_ *models.DesiredLRP) error {
					fakeBBS.DesiredLRPByProcessGuidReturns(&models.DesiredLRP{
						ProcessGuid: "some-guid",
					}, nil)
					return models.ErrResourceExists
				}
			})

			It("retries", func() {
				Expect(fakeBBS.DesireLRPCallCount()).To(Equal(1))
				Expect(fakeBBS.UpdateDesiredLRPCallCount()).To(Equal(1))
			})

			It("suceeds if the second try is sucessful", func() {
				Expect(responseRecorder.Code).To(Equal(http.StatusAccepted))
			})

			Context("when updating the desired LRP fails with a conflict error", func() {
				BeforeEach(func() {