예제 #1
0
	})

	Describe("#Set", func() {
		It("calls SET on the redis connection", func() {
			var setCalled bool
			fakeConnection.RespondToDo(func(command string, args ...interface{}) (interface{}, error) {
				setCalled = true
				Expect(command).To(Equal("SET"))
				Expect(args[0]).To(HaveLen(2))
				Expect(args[0].([]interface{})[0]).To(Equal("my key"))
				Expect(args[0].([]interface{})[1]).To(Equal("my value"))

				return nil, nil
			})

			err := commander.Set("my key", "my value")
			Expect(err).To(BeNil())
			Expect(setCalled).To(BeTrue())
		})

		It("returns the redis error", func() {
			fakeConnection.RespondToDo(func(command string, args ...interface{}) (interface{}, error) {
				return nil, errors.New("set error")
			})

			err := commander.Set("my key", "my value")
			Expect(err.Error()).To(Equal("set error"))
		})
	})

	Describe("#Del", func() {