Ejemplo n.º 1
0
		Context("when the start is successful", func() {
			BeforeEach(func() {
				requestBody = &models.StartTaskRequest{
					TaskGuid: "task-guid",
					CellId:   "cell-id",
				}
			})

			JustBeforeEach(func() {
				request := newTestRequest(requestBody)
				handler.StartTask(responseRecorder, request)
			})

			It("calls StartTask", func() {
				Expect(fakeTaskDB.StartTaskCallCount()).To(Equal(1))
				taskLogger, taskGuid, cellId := fakeTaskDB.StartTaskArgsForCall(0)
				Expect(taskLogger.SessionName()).To(ContainSubstring("start-task"))
				Expect(taskGuid).To(Equal("task-guid"))
				Expect(cellId).To(Equal("cell-id"))
			})

			Context("when the task should start", func() {
				BeforeEach(func() {
					fakeTaskDB.StartTaskReturns(true, nil)
				})

				It("responds with true", func() {
					Expect(responseRecorder.Code).To(Equal(http.StatusOK))
					response := &models.StartTaskResponse{}
					err := response.Unmarshal(responseRecorder.Body.Bytes())
					Expect(err).NotTo(HaveOccurred())