From a6876ad84ae11c0dac85129748c9dcb6581507a4 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Tue, 13 Oct 2020 09:33:12 +0300 Subject: [PATCH] Move Scan test --- internal/proto/scan_test.go | 30 ------------------------------ redis_test.go | 12 ++++++++++++ 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/internal/proto/scan_test.go b/internal/proto/scan_test.go index 034648c7..5df3a6af 100644 --- a/internal/proto/scan_test.go +++ b/internal/proto/scan_test.go @@ -1,13 +1,8 @@ package proto_test import ( - "context" "encoding/json" - "errors" - "testing" - "time" - "github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8/internal/proto" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -52,28 +47,3 @@ var _ = Describe("ScanSlice", func() { })) }) }) - -func TestScan(t *testing.T) { - t.Parallel() - - t.Run("time", func(t *testing.T) { - t.Parallel() - - ctx := context.Background() - - rdb := redis.NewClient(&redis.Options{ - Addr: ":6379", - }) - - tm := time.Now() - rdb.Set(ctx, "now", tm, 0) - - var tm2 time.Time - rdb.Get(ctx, "now").Scan(&tm2) - - if !tm2.Equal(tm) { - t.Fatal(errors.New("tm2 and tm are not equal")) - } - }) - -} diff --git a/redis_test.go b/redis_test.go index c00afc0d..a9e88c9d 100644 --- a/redis_test.go +++ b/redis_test.go @@ -283,6 +283,18 @@ var _ = Describe("Client", func() { Expect(err).NotTo(HaveOccurred()) Expect(got).To(Equal(bigVal)) }) + + It("should set and scan time", func() { + tm := time.Now() + err := rdb.Set(ctx, "now", tm, 0).Err() + Expect(err).NotTo(HaveOccurred()) + + var tm2 time.Time + err = rdb.Get(ctx, "now").Scan(&tm2) + Expect(err).NotTo(HaveOccurred()) + + Expect(tm2).To(BeTemporally("==", tm)) + }) }) var _ = Describe("Client timeout", func() {