Test on WrapProcess

This commit is contained in:
Sukharev Maxim 2016-12-30 11:47:43 +07:00
parent 40594f7b02
commit 362efb0c49
1 changed files with 35 additions and 0 deletions

View File

@ -5,6 +5,9 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
redis "gopkg.in/redis.v5" redis "gopkg.in/redis.v5"
) )
@ -57,3 +60,35 @@ func wrapRedisProcess(client *redis.Client) {
} }
}) })
} }
var _ = Describe("Instrumentation", func() {
var client *redis.Client
BeforeEach(func() {
client = redis.NewClient(redisOptions())
Expect(client.FlushDb().Err()).NotTo(HaveOccurred())
})
AfterEach(func() {
Expect(client.Close()).NotTo(HaveOccurred())
})
Describe("WrapProcess", func() {
It("should call for client", func() {
wrapperFnCalled := false
client.WrapProcess(func(oldProcess func(redis.Cmder) error) func(redis.Cmder) error {
return func(cmd redis.Cmder) error {
wrapperFnCalled = true
return oldProcess(cmd)
}
})
client.Ping()
Expect(wrapperFnCalled).To(Equal(true))
})
})
})