예제 #1
0
			)

			BeforeEach(func() {
				cellPresence := models.NewCellPresence("cell-id", "1.1.1.1", "", "z1", models.CellCapacity{}, nil, nil, nil, nil)
				cellSet = models.CellSet{"cell-id": &cellPresence}
				fakeServiceClient.CellsReturns(cellSet, nil)
			})

			JustBeforeEach(func() {
				err = controller.ConvergeTasks(logger, kickTaskDuration, expirePendingTaskDuration, expireCompletedTaskDuration)
			})

			It("calls ConvergeTasks", func() {
				Expect(err).NotTo(HaveOccurred())
				Expect(fakeTaskDB.ConvergeTasksCallCount()).To(Equal(1))
				taskLogger, actualCellSet, actualKickDuration, actualPendingDuration, actualCompletedDuration := fakeTaskDB.ConvergeTasksArgsForCall(0)
				Expect(taskLogger.SessionName()).To(ContainSubstring("converge-tasks"))
				Expect(actualCellSet).To(BeEquivalentTo(cellSet))
				Expect(actualKickDuration).To(BeEquivalentTo(kickTaskDuration))
				Expect(actualPendingDuration).To(BeEquivalentTo(expirePendingTaskDuration))
				Expect(actualCompletedDuration).To(BeEquivalentTo(expireCompletedTaskDuration))
			})

			Context("when fetching cells fails", func() {
				BeforeEach(func() {
					fakeServiceClient.CellsReturns(nil, errors.New("kaboom"))
				})

				It("does not call ConvergeTasks", func() {
					Expect(err).To(MatchError("kaboom"))
					Expect(fakeTaskDB.ConvergeTasksCallCount()).To(Equal(0))