Exemplo n.º 1
0
				It("calls ConvergeTasks with an empty CellSet", func() {
					Expect(responseRecorder.Code).To(Equal(http.StatusOK))
					Expect(fakeTaskDB.ConvergeTasksCallCount()).To(Equal(1))
					_, actualCellSet, _, _, _ := fakeTaskDB.ConvergeTasksArgsForCall(0)
					Expect(actualCellSet).To(BeEquivalentTo(models.CellSet{}))
				})
			})

			Context("when there are tasks to complete", func() {
				const taskGuid1 = "to-complete-1"
				const taskGuid2 = "to-complete-2"

				BeforeEach(func() {
					task1 := model_helpers.NewValidTask(taskGuid1)
					task2 := model_helpers.NewValidTask(taskGuid2)
					fakeTaskDB.ConvergeTasksReturns(nil, []*models.Task{task1, task2})
				})

				It("submits the tasks to the workpool", func() {
					expectedCallCount := 2
					Expect(fakeTaskCompletionClient.SubmitCallCount()).To(Equal(expectedCallCount))

					_, submittedTask1 := fakeTaskCompletionClient.SubmitArgsForCall(0)
					_, submittedTask2 := fakeTaskCompletionClient.SubmitArgsForCall(1)
					Expect([]string{submittedTask1.TaskGuid, submittedTask2.TaskGuid}).To(ConsistOf(taskGuid1, taskGuid2))

					task1Completions := 0
					task2Completions := 0
					for i := 0; i < expectedCallCount; i++ {
						db, task := fakeTaskCompletionClient.SubmitArgsForCall(i)
						Expect(db).To(Equal(fakeTaskDB))