本文整理汇总了Golang中github.com/cloudfoundry-incubator/pat/context.Context.PutBool方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.PutBool方法的具体用法?Golang Context.PutBool怎么用?Golang Context.PutBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-incubator/pat/context.Context
的用法示例。
在下文中一共展示了Context.PutBool方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
It("can store string value as provided", func() {
localContext.PutString("str", "This is a long string \n")
result, _ := localContext.GetString("str")
Ω(result).Should(Equal("This is a long string \n"))
})
It("can store int value as provided", func() {
localContext.PutInt("int", 123)
result, _ := localContext.GetInt("int")
Ω(result).Should(Equal(123))
})
It("can store bool value as provided", func() {
localContext.PutBool("key", true)
result, _ := localContext.GetBool("key")
Ω(result).Should(Equal(true))
})
It("can store float64 value as provided", func() {
localContext.PutFloat64("key", float64(3.14))
result, _ := localContext.GetFloat64("key")
Ω(result).Should(Equal(float64(3.14)))
})
})
Context("Cloning map", func() {
It("returns a copy of the cloned context map", func() {
示例2:
workloadCtx.PutString("RandomKey", "some info")
_ = worker.Time("recordWorkerInfo", workloadCtx)
Ω(wasCalledWithWorkerUsername).Should(Equal("user1"))
Ω(wasCalledWithRandomKey).Should(Equal("some info"))
})
It("should retain 'int' type content when sending over redis", func() {
worker := NewRedisWorker(conn)
workloadCtx.PutInt("iterationIndex", 100)
_ = worker.Time("recordWorkerIndex", workloadCtx)
Ω(wasCalledWithWorkerIndex).Should(Equal(100))
})
It("should retain 'bool' type content when sending over redis", func() {
worker := NewRedisWorker(conn)
workloadCtx.PutBool("boolTypeKey", true)
_ = worker.Time("recordWorkerBool", workloadCtx)
Ω(wasCalledWithBoolTypeKey).Should(Equal(true))
})
})
Describe("When content string contain spaces", func() {
It("should run on slave worker with no errors", func() {
worker := NewRedisWorker(conn)
workloadCtx.PutString("cfPassword", "pass1, pass2, pass3")
result := worker.Time("foo", workloadCtx)
Ω(result.Error).Should(BeNil())
})
It("should retain all the spaces in content while passing over redis", func() {