a3.DesiredState(1),
		})

		conf, _ = config.DefaultConfig()

		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())

		fetcher = desiredstatefetcher.New(conf, store, fakemetricsaccountant.New(), httpclient.NewHttpClient(conf.SkipSSLVerification, conf.FetcherNetworkTimeout()), &timeprovider.RealTimeProvider{}, fakelogger.NewFakeLogger())
		fetcher.Fetch(resultChan)
	})

	It("requests for the first set of data from the CC and stores the response", func() {
		var desired map[string]models.DesiredAppState
		var err error
		Eventually(func() interface{} {
			desired, err = store.GetDesiredState()
			return desired
		}, 1, 0.1).ShouldNot(BeEmpty())

		Ω(desired).Should(HaveKey(a1.AppGuid + "," + a1.AppVersion))
		Ω(desired).Should(HaveKey(a2.AppGuid + "," + a2.AppVersion))
		Ω(desired).Should(HaveKey(a3.AppGuid + "," + a3.AppVersion))
	})

	It("bumps the freshness", func() {
		Eventually(func() error {
			_, err := storeAdapter.Get("/hm/v1" + conf.DesiredFreshnessKey)
			return err
		}, 1, 0.1).ShouldNot(HaveOccurred())
	})
コード例 #2
0
						a1.AppGuid:                a1.DesiredState(1),
						a2.AppGuid:                a2.DesiredState(1),
						stoppedApp.AppGuid:        stoppedDesiredState,
						pendingStagingApp.AppGuid: pendingStagingDesiredState,
						failedToStageApp.AppGuid:  failedStagingDesiredState,
					},
					BulkToken: BulkToken{
						Id: 5,
					},
				}

				httpClient.LastRequest().Succeed(response.ToJSON())
			})

			It("should not store the desired state (yet)", func() {
				desired, _ := store.GetDesiredState()
				Ω(desired).Should(HaveLen(1))
				Ω(desired[deletedApp.DesiredState(1).StoreKey()]).Should(EqualDesiredState(deletedApp.DesiredState(1)))
			})

			It("should request the next batch", func() {
				Ω(httpClient.Requests).Should(HaveLen(2))
				Ω(httpClient.LastRequest().URL.Query().Get("bulk_token")).Should(Equal(response.BulkTokenRepresentation()))
			})

			It("should not bump the freshness yet", func() {
				fresh, _ := store.IsDesiredStateFresh()
				Ω(fresh).Should(BeFalse())
			})

			It("should not send a result down the resultChan yet", func() {