本文整理汇总了Golang中github.com/cloudfoundry/storeadapter/fakestoreadapter.FakeStoreAdapter.ConnectErr方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeStoreAdapter.ConnectErr方法的具体用法?Golang FakeStoreAdapter.ConnectErr怎么用?Golang FakeStoreAdapter.ConnectErr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/storeadapter/fakestoreadapter.FakeStoreAdapter
的用法示例。
在下文中一共展示了FakeStoreAdapter.ConnectErr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
gosteno.EnterTestMode()
testingSink = gosteno.GetMeTheGlobalTestSink()
fakeStore = fakestoreadapter.New()
logger = gosteno.NewLogger("test")
})
Context("at initialization", func() {
It("connects to the store", func() {
elector.NewElector("name", fakeStore, 1*time.Millisecond, logger)
Expect(fakeStore.DidConnect).To(BeTrue())
})
Context("when store connection fails", func() {
BeforeEach(func() {
fakeStore.ConnectErr = errors.New("connection error")
})
It("logs an error", func() {
go elector.NewElector("name", fakeStore, 100*time.Millisecond, logger)
Eventually(func() int { return len(testingSink.Records()) }).Should(BeNumerically(">=", 1))
var messages []string
for _, record := range testingSink.Records() {
messages = append(messages, record.Message)
}
Expect(messages).To(ContainElement("Elector: Unable to connect to store: 'connection error'"))
})
It("reconnects on an interval", func() {