예제 #1
0
		var err error
		request, err = http.NewRequest("DELETE", "", nil)
		Expect(err).NotTo(HaveOccurred())
		request.Form = url.Values{
			":process_guid": []string{"process-guid"},
		}
	})

	JustBeforeEach(func() {
		stopAppHandler := handlers.NewStopAppHandler(logger, fakeBBS)
		stopAppHandler.StopApp(responseRecorder, request)
	})

	It("invokes the bbs to delete the app", func() {
		Expect(fakeBBS.RemoveDesiredLRPCallCount()).To(Equal(1))
		Expect(fakeBBS.RemoveDesiredLRPArgsForCall(0)).To(Equal("process-guid"))
	})

	It("responds with 202 Accepted", func() {
		Expect(responseRecorder.Code).To(Equal(http.StatusAccepted))
	})

	Context("when the bbs fails", func() {
		BeforeEach(func() {
			fakeBBS.RemoveDesiredLRPReturns(errors.New("oh no"))
		})

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