})

					It("fails and does not request an auction", func() {
						Expect(responseRecorder.Code).To(Equal(http.StatusOK))
						response := &models.ActualLRPLifecycleResponse{}
						err := response.Unmarshal(responseRecorder.Body.Bytes())
						Expect(err).NotTo(HaveOccurred())
						Expect(response.Error.Error()).To(Equal("error occured"))

						Expect(fakeAuctioneerClient.RequestLRPAuctionsCallCount()).To(Equal(0))
					})
				})

				Context("when requesting the auction fails", func() {
					BeforeEach(func() {
						fakeAuctioneerClient.RequestLRPAuctionsReturns(errors.New("some else bid higher"))
					})

					It("returns an error", func() {
						Expect(responseRecorder.Code).To(Equal(http.StatusOK))
						response := &models.ActualLRPLifecycleResponse{}
						err := response.Unmarshal(responseRecorder.Body.Bytes())
						Expect(err).NotTo(HaveOccurred())
						Expect(response.Error.Error()).To(Equal("some else bid higher"))
					})
				})
			})
		})

		Context("when the DB returns an unrecoverable error", func() {
			BeforeEach(func() {
Ejemplo n.º 2
0
					Expect(response.Error.Error()).To(Equal("can't unclaim this"))
				})

				It("only emits events for deleting evacuating", func() {
					Eventually(actualHub.EmitCallCount).Should(Equal(1))
					event := actualHub.EmitArgsForCall(0)
					removeEvent, ok := event.(*models.ActualLRPRemovedEvent)
					Expect(ok).To(BeTrue())
					Expect(removeEvent.ActualLrpGroup).To(Equal(&models.ActualLRPGroup{Evacuating: actual}))
				})
			})
		})

		Context("when requesting the lrp auction fails", func() {
			BeforeEach(func() {
				fakeAuctioneerClient.RequestLRPAuctionsReturns(errors.New("boom!"))
			})

			It("does not return the error or keep the container", func() {
				response := models.EvacuationResponse{}
				err := response.Unmarshal(responseRecorder.Body.Bytes())
				Expect(err).NotTo(HaveOccurred())
				Expect(response.KeepContainer).To(BeFalse())
				Expect(response.Error).To(BeNil())
			})
		})

		Context("when the request is invalid", func() {
			BeforeEach(func() {
				request = newTestRequest("{{")
			})