當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakeStoreAdapter.Get方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/storeadapter/fakestoreadapter.FakeStoreAdapter.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeStoreAdapter.Get方法的具體用法?Golang FakeStoreAdapter.Get怎麽用?Golang FakeStoreAdapter.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry/storeadapter/fakestoreadapter.FakeStoreAdapter的用法示例。


在下文中一共展示了FakeStoreAdapter.Get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

	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())
	})

	It("reports success to the channel", func() {
		result := <-resultChan
		Ω(result.Success).Should(BeTrue())
		Ω(result.NumResults).Should(Equal(3))
		Ω(result.Message).Should(BeZero())
		Ω(result.Error).ShouldNot(HaveOccurred())
	})

	Context("when fetching again, and apps have been stopped and/or deleted", func() {
		BeforeEach(func() {
			<-resultChan
開發者ID:nkts,項目名稱:golang-devops-stuff,代碼行數:31,代碼來源:desired_state_fetcher_integration_test.go

示例2:

			})
		})
	})

	Describe("RunForElection", func() {
		var candidate *elector.Elector

		BeforeEach(func() {
			candidate = elector.NewElector("name", fakeStore, time.Second, logger)
		})

		It("makes a bid to become leader", func() {
			err := candidate.RunForElection()
			Expect(err).NotTo(HaveOccurred())

			node, err := fakeStore.Get("syslog_drain_binder/leader")
			Expect(err).NotTo(HaveOccurred())
			Expect(node.Value).To(BeEquivalentTo("name"))
			Expect(node.TTL).To(Equal(uint64(1)))
		})

		It("sets the IsLeader flag to true", func() {
			candidate.RunForElection()
			Expect(candidate.IsLeader()).To(BeTrue())
		})

		It("re-attempts on an interval if key already exists", func() {
			err := fakeStore.Create(storeadapter.StoreNode{
				Key:   "syslog_drain_binder/leader",
				Value: []byte("some-other-instance"),
			})
開發者ID:lyuyun,項目名稱:loggregator,代碼行數:31,代碼來源:elector_test.go

示例3:

			{Key: "/hm/v2/pokemon/geodude", Value: []byte{}},
			{Key: "/hm/v2/deep-pokemon/abra/kadabra/alakazam", Value: []byte{}},
			{Key: "/hm/v2/pokemonCount", Value: []byte("151")},
			{Key: "/hm/v1/nuke/me/cause/im/an/old/version", Value: []byte("abc")},
			{Key: "/hm/v3/leave/me/alone/since/im/a/new/version", Value: []byte("abc")},
			{Key: "/hm/nuke/me/cause/im/not/versioned", Value: []byte("abc")},
			{Key: "/let/me/be", Value: []byte("abc")},
		})

		storeAdapter.Delete("/hm/v2/pokemon/geodude", "/hm/v2/deep-pokemon/abra/kadabra/alakazam")
		err := shredder.Shred()
		Ω(err).ShouldNot(HaveOccurred())
	})

	It("should delete empty directories", func() {
		_, err := storeAdapter.Get("/hm/v2/pokemon")
		Ω(err).Should(Equal(storeadapter.ErrorKeyNotFound))

		_, err = storeAdapter.Get("/hm/v2/deep-pokemon")
		Ω(err).Should(Equal(storeadapter.ErrorKeyNotFound))

		_, err = storeAdapter.Get("/hm/v2/pokemonCount")
		Ω(err).ShouldNot(HaveOccurred())
	})

	It("should delete everything underneath older versions", func() {
		_, err := storeAdapter.Get("/hm/v1/nuke/me/cause/im/an/old/version")
		Ω(err).Should(Equal(storeadapter.ErrorKeyNotFound))
	})

	It("should delete everything that is not versioned", func() {
開發者ID:nkts,項目名稱:golang-devops-stuff,代碼行數:31,代碼來源:shredder_test.go


注:本文中的github.com/cloudfoundry/storeadapter/fakestoreadapter.FakeStoreAdapter.Get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。