Exemple #1
0
		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() {
Exemple #2
0
						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() {