} }) JustBeforeEach(func() { request := newTestRequest(requestBody) handler.DesireDesiredLRP(responseRecorder, request) }) Context("when creating desired lrp in DB succeeds", func() { BeforeEach(func() { fakeDesiredLRPDB.DesireLRPReturns(nil) }) It("creates desired lrp", func() { Expect(fakeDesiredLRPDB.DesireLRPCallCount()).To(Equal(1)) _, actualDesiredLRP := fakeDesiredLRPDB.DesireLRPArgsForCall(0) Expect(actualDesiredLRP).To(Equal(desiredLRP)) Expect(responseRecorder.Code).To(Equal(http.StatusOK)) response := models.DesiredLRPLifecycleResponse{} err := response.Unmarshal(responseRecorder.Body.Bytes()) Expect(err).NotTo(HaveOccurred()) Expect(response.Error).To(BeNil()) }) }) Context("when the DB errors out", func() { BeforeEach(func() { fakeDesiredLRPDB.DesireLRPReturns(models.ErrUnknownError) })