当前位置: 首页>>代码示例>>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;未经允许,请勿转载。