本文整理汇总了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
示例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"),
})
示例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() {