} messageBus.Subscriptions["dea.heartbeat"][0].Callback(heartbeat.ToJson()) }) It("Stores it in the store", func() { actual, _ := store.GetActualState() Ω(actual).Should(ContainElement(app.GetInstance(0).Heartbeat(17))) Ω(actual).Should(ContainElement(app.GetInstance(1).Heartbeat(22))) Ω(actual).Should(ContainElement(anotherApp.GetInstance(0).Heartbeat(11))) }) Context("when the save succeeds", func() { It("bumps the freshness", func() { Ω(store.ActualIsFresh).Should(BeTrue()) Ω(store.ActualFreshnessTimestamp).Should(Equal(timeProvider.Time())) Ω(logger.LoggedSubjects).Should(BeEmpty()) }) Context("when the freshness bump fails", func() { BeforeEach(func() { store.BumpActualFreshnessError = errors.New("oops") }) It("logs about the failed freshness bump", func() { Ω(logger.LoggedSubjects).Should(ContainElement("Could not update actual freshness")) }) }) }) Context("when the save fails", func() {
Results: map[string]models.DesiredAppState{}, BulkToken: BulkToken{ Id: 17, }, } httpClient.LastRequest().Succeed(response.ToJson()) }) It("should stop requesting batches", func() { Ω(httpClient.Requests).Should(HaveLen(1)) }) It("should bump the freshness", func() { Ω(store.DesiredIsFresh).Should(BeTrue()) Ω(store.DesiredFreshnessTimestamp).Should(Equal(timeProvider.Time())) }) It("should send a succesful result down the result channel", func(done Done) { result := <-resultChan Ω(result.Success).Should(BeTrue()) Ω(result.Message).Should(BeZero()) Ω(result.Error).ShouldNot(HaveOccured()) close(done) }, 0.1) }) assertFailure := func(expectedMessage string) { It("should stop requesting batches", func() { Ω(httpClient.Requests).Should(HaveLen(1)) })