From 362efb0c4949154c2c2a381660498be85a0da339 Mon Sep 17 00:00:00 2001 From: Sukharev Maxim Date: Fri, 30 Dec 2016 11:47:43 +0700 Subject: [PATCH] Test on WrapProcess --- example_instrumentation_test.go | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/example_instrumentation_test.go b/example_instrumentation_test.go index 009138eb..a627586b 100644 --- a/example_instrumentation_test.go +++ b/example_instrumentation_test.go @@ -5,6 +5,9 @@ import ( "sync/atomic" "time" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + 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)) + }) + + }) +})