diff --git a/example_instrumentation_test.go b/example_instrumentation_test.go index a627586..009138e 100644 --- a/example_instrumentation_test.go +++ b/example_instrumentation_test.go @@ -5,9 +5,6 @@ import ( "sync/atomic" "time" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - redis "gopkg.in/redis.v5" ) @@ -60,35 +57,3 @@ 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)) - }) - - }) -}) diff --git a/redis.go b/redis.go index 3e9ee07..894294d 100644 --- a/redis.go +++ b/redis.go @@ -293,12 +293,14 @@ type Client struct { } func newClient(opt *Options, pool pool.Pooler) *Client { - base := baseClient{opt: opt, connPool: pool} - client := &Client{ - baseClient: base, - cmdable: cmdable{base.Process}, + client := Client{ + baseClient: baseClient{ + opt: opt, + connPool: pool, + }, } - return client + client.cmdable.process = client.Process + return &client } // NewClient returns a client to the Redis Server specified by Options. diff --git a/redis_test.go b/redis_test.go index e15c871..69c68df 100644 --- a/redis_test.go +++ b/redis_test.go @@ -199,6 +199,21 @@ var _ = Describe("Client", func() { Expect(err).NotTo(HaveOccurred()) Expect(got).To(Equal(bigVal)) }) + + It("should call WrapProcess", func() { + var wrapperFnCalled bool + + client.WrapProcess(func(oldProcess func(redis.Cmder) error) func(redis.Cmder) error { + return func(cmd redis.Cmder) error { + wrapperFnCalled = true + return oldProcess(cmd) + } + }) + + Expect(client.Ping().Err()).NotTo(HaveOccurred()) + + Expect(wrapperFnCalled).To(BeTrue()) + }) }) var _ = Describe("Client timeout", func() {