示例#1
0
			Ω(exists).Should(Equal(true))

			result, exists = localContext.GetString("key2")
			Ω(result).Should(Equal("123"))
			Ω(exists).Should(Equal(true))
		})

		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))
示例#2
0
文件: redis_test.go 项目: nkuacac/pat
		StartRedis("../redis/redis.conf")
		var err error
		conn, err = redis.Connect("", 63798, "p4ssw0rd")
		Ω(err).ShouldNot(HaveOccurred())
		workloadCtx = context.New()
	})

	AfterEach(func() {
		StopRedis()
	})

	Describe("When a single experiment is provided", func() {
		Context("When no slaves are running", func() {
			It("Times out after a specified time", func() {
				worker := NewRedisWorkerWithTimeout(conn, 1)
				workloadCtx.PutInt("iterationIndex", 0)
				worker.AddWorkloadStep(workloads.Step("timesout", func() error { time.Sleep(10 * time.Second); return nil }, ""))
				result := make(chan error)
				go func() {
					result <- worker.Time("timesout", workloadCtx).Error
				}()
				Eventually(result, 2).Should(Receive())
			})
		})

		Context("When a slave is running", func() {
			var (
				slave                       io.Closer
				delegate                    *LocalWorker
				wasCalledWithWorkerIndex    int
				wasCalledWithWorkerUsername string