示例#1
0
						}, 2*domainTTL).ShouldNot(BeNil())
					})
				})

				Context("The BBS has a task, but the CC does not", func() {
					BeforeEach(func() {
						fakeCC.RouteToHandler("GET", "/internal/v3/bulk/task_states",
							ghttp.RespondWith(200, `{ "token": {}, "task_states": [] }`),
						)

						taskResponse := models.TasksResponse{
							Tasks: []*models.Task{
								{
									TaskGuid: "task-guid-1",
									State:    models.Task_Completed,
									Domain:   cc_messages.RunningTaskDomain,
									TaskDefinition: &models.TaskDefinition{
										CompletionCallbackUrl: "/internal/v3/tasks/task-guid-1/completed",
									},
								},
							},
						}
						data, err := taskResponse.Marshal()
						Expect(err).ToNot(HaveOccurred())

						fakeBBS.RouteToHandler("POST", "/v1/tasks/list.r1",
							ghttp.RespondWith(200, data, http.Header{bbs.ContentTypeHeader: []string{bbs.ProtoContentType}}),
						)

						fakeBBS.RouteToHandler("POST", "/v1/desired_lrp_scheduling_infos/list",
							ghttp.RespondWith(200, `{"error":{},"desired_lrp_scheduling_infos":	[]}`),
						)
示例#2
0
		JustBeforeEach(func() {
			request := newTestRequest(requestBody)
			handler.Tasks(responseRecorder, request)
		})

		Context("when reading tasks from DB succeeds", func() {
			var tasks []*models.Task

			BeforeEach(func() {
				tasks = []*models.Task{&task1, &task2}
				fakeTaskDB.TasksReturns(tasks, nil)
			})

			It("returns a list of task", func() {
				Expect(responseRecorder.Code).To(Equal(http.StatusOK))
				response := models.TasksResponse{}
				err := response.Unmarshal(responseRecorder.Body.Bytes())
				Expect(err).NotTo(HaveOccurred())

				Expect(response.Error).To(BeNil())
				Expect(response.Tasks).To(Equal(tasks))
			})

			It("calls the DB with no filter", func() {
				Expect(fakeTaskDB.TasksCallCount()).To(Equal(1))
				_, filter := fakeTaskDB.TasksArgsForCall(0)
				Expect(filter).To(Equal(models.TaskFilter{}))
			})

			Context("and filtering by domain", func() {
				BeforeEach(func() {