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


Golang FakeStoreAdapter.Delete方法代碼示例

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


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

示例1:

					Ω(err).ShouldNot(HaveOccurred())
					Ω(startMessages()).Should(BeEmpty())

					Ω(stopMessages()).Should(HaveLen(2))

					expectedMessage := models.NewPendingStopMessage(clock.Now(), 0, conf.GracePeriod(), app.AppGuid, app.AppVersion, app.InstanceAtIndex(1).InstanceGuid, models.PendingStopMessageReasonExtra)
					Ω(stopMessages()).Should(ContainElement(EqualPendingStopMessage(expectedMessage)))

					expectedMessage = models.NewPendingStopMessage(clock.Now(), 0, conf.GracePeriod(), app.AppGuid, app.AppVersion, app.InstanceAtIndex(2).InstanceGuid, models.PendingStopMessageReasonExtra)
					Ω(stopMessages()).Should(ContainElement(EqualPendingStopMessage(expectedMessage)))
				})
			})

			Context("and desired instances are missing", func() {
				BeforeEach(func() {
					storeAdapter.Delete("/hm/v1/apps/actual/" + app.AppGuid + "," + app.AppVersion + "/" + app.InstanceAtIndex(0).InstanceGuid)
				})

				It("should return a start message containing the missing indices and no stop messages", func() {
					err := analyzer.Analyze()
					Ω(err).ShouldNot(HaveOccurred())

					Ω(startMessages()).Should(HaveLen(1))

					expectedMessage := models.NewPendingStartMessage(clock.Now(), conf.GracePeriod(), 0, app.AppGuid, app.AppVersion, 0, 1.0, models.PendingStartMessageReasonMissing)
					Ω(startMessages()).Should(ContainElement(EqualPendingStartMessage(expectedMessage)))

					Ω(stopMessages()).Should(BeEmpty())
				})
			})
		})
開發者ID:nagyistge,項目名稱:hm9000,代碼行數:31,代碼來源:analyzer_test.go

示例2:

		It("returns nil when it eventually wins", func() {
			preExistingNode := storeadapter.StoreNode{
				Key:   "syslog_drain_binder/leader",
				Value: []byte("some-other-instance"),
			}
			err := fakeStore.Create(preExistingNode)
			Expect(err).NotTo(HaveOccurred())

			errChan := make(chan error)
			go func() {
				errChan <- candidate.RunForElection()
			}()

			time.Sleep(1 * time.Second)
			fakeStore.Delete(preExistingNode.Key)
			Eventually(errChan, 2).Should(Receive(BeNil()))
		})
	})

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

		BeforeEach(func() {
			fakeStore.Create(storeadapter.StoreNode{
				Key:   "syslog_drain_binder/leader",
				Value: []byte("candidate1"),
			})
		})

		Context("when already leader", func() {
開發者ID:lyuyun,項目名稱:loggregator,代碼行數:30,代碼來源:elector_test.go

示例3:

		conf, _ := config.DefaultConfig()
		conf.StoreSchemaVersion = 2
		store := storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
		shredder = New(store)

		storeAdapter.SetMulti([]storeadapter.StoreNode{
			{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())
	})
開發者ID:nkts,項目名稱:golang-devops-stuff,代碼行數:30,代碼來源:shredder_test.go


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