本文整理汇总了Golang中github.com/cloudfoundry/storeadapter.StoreAdapter.Delete方法的典型用法代码示例。如果您正苦于以下问题:Golang StoreAdapter.Delete方法的具体用法?Golang StoreAdapter.Delete怎么用?Golang StoreAdapter.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/storeadapter.StoreAdapter
的用法示例。
在下文中一共展示了StoreAdapter.Delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Ω(app).Should(BeZero())
})
})
Context("when the app is not found", func() {
It("should return the app not found error", func() {
app, err := store.GetApp("Marzipan", "Armadillo")
Ω(err).Should(Equal(AppNotFoundError))
Ω(app).Should(BeZero())
})
})
Context("when the app directory is empty", func() {
It("should return the app not found error", func() {
storeAdapter.SetMulti([]storeadapter.StoreNode{{
Key: "/hm/v1/apps/actual/foo-bar/baz",
Value: []byte("foo"),
}})
storeAdapter.Delete("/hm/v1/apps/actual/foo-bar/baz")
app, err := store.GetApp("foo", "bar")
Ω(err).Should(Equal(AppNotFoundError))
Ω(app).Should(BeZero())
})
})
})
})
})
示例2:
})
})
})
Context("when services exists", func() {
JustBeforeEach(func() {
err := storeAdapter.Create(node)
Expect(err).NotTo(HaveOccurred())
finder.Start()
Eventually(finder.AllServers).ShouldNot(HaveLen(0))
Expect(finder.PreferredServers()).NotTo(HaveLen(0))
})
It("removes the service", func() {
err := storeAdapter.Delete(node.Key)
Expect(err).NotTo(HaveOccurred())
Eventually(finder.AllServers).Should(BeEmpty())
Expect(getCallbackCount()).To(Equal(2))
Expect(finder.PreferredServers()).To(BeEmpty())
Expect(getPreferredCount()).To(Equal(1))
})
It("only finds nodes for the doppler server type", func() {
router := storeadapter.StoreNode{
Key: "/healthstatus/router/z1/router_z1",
Value: []byte("10.99.99.99"),
}
storeAdapter.Create(router)
Consistently(finder.AllServers).Should(Equal(expectedAddress))
示例3:
})
})
Describe("Recursively deleting empty directories", func() {
BeforeEach(func() {
storeAdapter.SetMulti([]storeadapter.StoreNode{
{Key: "/hm/v17/pokemon/geodude", Value: []byte("foo")},
{Key: "/hm/v17/deep-pokemon/abra/kadabra/alakazam", Value: []byte{}},
{Key: "/hm/v17/pokemonCount", Value: []byte("151")},
})
})
Context("when the node is a directory", func() {
Context("and it is empty", func() {
BeforeEach(func() {
storeAdapter.Delete("/hm/v17/pokemon/geodude")
})
It("shreds it mercilessly", func() {
err := store.Compact()
Ω(err).ShouldNot(HaveOccurred())
_, err = storeAdapter.Get("/hm/v17/pokemon")
Ω(err).Should(Equal(storeadapter.ErrorKeyNotFound))
})
})
Context("and it is non-empty", func() {
It("spares it", func() {
err := store.Compact()
Ω(err).ShouldNot(HaveOccurred())
示例4:
})
})
})
Context("When an existing service is updated", func() {
It("should not notify the channel again", func() {
adapter.SetMulti([]storeadapter.StoreNode{buildNode(app2Service1)})
assertNoDataOnChannel(outAddChan)
assertNoDataOnChannel(outRemoveChan)
})
})
Context("when a service or app should be removed", func() {
Context("when an existing app loses one of its services", func() {
It("sends that service on the output remove channel", func(done Done) {
adapter.Delete(path.Join("/loggregator/services", app1Service2.AppId, app1Service2.Id()))
Expect(<-outRemoveChan).To(Equal(app1Service2))
assertNoDataOnChannel(outAddChan)
close(done)
})
})
Context("when an existing app loses all of its services", func() {
It("sends all of the app services on the outgoing remove channel", func(done Done) {
adapter.Delete(path.Join("/loggregator/services", app1Service2.AppId))
appServices := drainOutgoingChannel(outRemoveChan, 2)
Expect(appServices).To(ContainElement(app1Service1))
示例5:
})
})
})
Context("When an existing service is updated", func() {
It("should not notify the channel again", func() {
adapter.SetMulti([]storeadapter.StoreNode{buildNode(app2Service1)})
Expect(outAddChan).To(BeEmpty())
Expect(outRemoveChan).To(BeEmpty())
})
})
Context("when a service or app should be removed", func() {
Context("when an existing app loses one of its services", func() {
It("sends that service on the output remove channel", func() {
err := adapter.Delete(key(app1Service2))
Expect(err).NotTo(HaveOccurred())
var appService appservice.AppService
Eventually(outRemoveChan).Should(Receive(&appService))
Expect(appService).To(Equal(app1Service2))
Expect(outAddChan).To(BeEmpty())
})
})
Context("when an existing app loses all of its services", func() {
It("sends all of the app services on the outgoing remove channel", func() {
adapter.Get(path.Join("/loggregator/services", APP1_ID))
adapter.Delete(path.Join("/loggregator/services", APP1_ID))
appServices := drainOutgoingChannel(outRemoveChan, 2)
示例6:
dea.GetApp(0).InstanceAtIndex(1).Heartbeat(),
))
}()
err1 := <-done
err2 := <-done
Ω(err1).ShouldNot(HaveOccurred())
Ω(err2).ShouldNot(HaveOccurred())
})
})
Context("when something goes wrong and the in-memory cache no longer matches the store", func() {
It("should eventually recover", func() {
//Delete one of the heartbeats
corruptedHeartbeat := dea.GetApp(0).InstanceAtIndex(1).Heartbeat()
storeAdapter.Delete("/hm/v1/apps/actual/" + store.AppKey(corruptedHeartbeat.AppGuid, corruptedHeartbeat.AppVersion) + "/" + corruptedHeartbeat.InstanceGuid)
//See that it's gone
results, err := store.GetInstanceHeartbeats()
Ω(err).ShouldNot(HaveOccurred())
Ω(results).Should(HaveLen(1))
//Try to put it back
store.SyncHeartbeats(dea.HeartbeatWith(
dea.GetApp(0).InstanceAtIndex(1).Heartbeat(),
dea.GetApp(1).InstanceAtIndex(3).Heartbeat(),
))
//See that we didn't... because it's still in the cache...
results, err = store.GetInstanceHeartbeats()
Ω(err).ShouldNot(HaveOccurred())