Skip to content

Commit a6876ad

Browse files
committed
Move Scan test
1 parent f169894 commit a6876ad

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

internal/proto/scan_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
package proto_test
22

33
import (
4-
"context"
54
"encoding/json"
6-
"errors"
7-
"testing"
8-
"time"
95

10-
"github.com/go-redis/redis/v8"
116
"github.com/go-redis/redis/v8/internal/proto"
127
. "github.com/onsi/ginkgo"
138
. "github.com/onsi/gomega"
@@ -52,28 +47,3 @@ var _ = Describe("ScanSlice", func() {
5247
}))
5348
})
5449
})
55-
56-
func TestScan(t *testing.T) {
57-
t.Parallel()
58-
59-
t.Run("time", func(t *testing.T) {
60-
t.Parallel()
61-
62-
ctx := context.Background()
63-
64-
rdb := redis.NewClient(&redis.Options{
65-
Addr: ":6379",
66-
})
67-
68-
tm := time.Now()
69-
rdb.Set(ctx, "now", tm, 0)
70-
71-
var tm2 time.Time
72-
rdb.Get(ctx, "now").Scan(&tm2)
73-
74-
if !tm2.Equal(tm) {
75-
t.Fatal(errors.New("tm2 and tm are not equal"))
76-
}
77-
})
78-
79-
}

redis_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ var _ = Describe("Client", func() {
283283
Expect(err).NotTo(HaveOccurred())
284284
Expect(got).To(Equal(bigVal))
285285
})
286+
287+
It("should set and scan time", func() {
288+
tm := time.Now()
289+
err := rdb.Set(ctx, "now", tm, 0).Err()
290+
Expect(err).NotTo(HaveOccurred())
291+
292+
var tm2 time.Time
293+
err = rdb.Get(ctx, "now").Scan(&tm2)
294+
Expect(err).NotTo(HaveOccurred())
295+
296+
Expect(tm2).To(BeTemporally("==", tm))
297+
})
286298
})
287299

288300
var _ = Describe("Client timeout", func() {

0 commit comments

Comments
 (0)