Esempio n. 1
0
	It("should discard", func() {
		pipeline := client.Pipeline()

		pipeline.Get("key")
		pipeline.Discard()
		cmds, err := pipeline.Exec()
		Expect(err).NotTo(HaveOccurred())
		Expect(cmds).To(HaveLen(0))
		Expect(pipeline.Close()).NotTo(HaveOccurred())
	})

	It("should support block style", func() {
		var get *redis.StringCmd
		cmds, err := client.Pipelined(func(pipe *redis.Pipeline) error {
			get = pipe.Get("foo")
			return nil
		})
		Expect(err).To(Equal(redis.Nil))
		Expect(cmds).To(HaveLen(1))
		Expect(cmds[0]).To(Equal(get))
		Expect(get.Err()).To(Equal(redis.Nil))
		Expect(get.Val()).To(Equal(""))
	})

	It("should handle vals/err", func() {
		pipeline := client.Pipeline()

		get := pipeline.Get("key")
		Expect(get.Err()).NotTo(HaveOccurred())
		Expect(get.Val()).To(Equal(""))
		Expect(pipeline.Close()).NotTo(HaveOccurred())