forked from mirror/redis
Move Scan test
This commit is contained in:
parent
f169894120
commit
a6876ad84a
|
@ -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"))
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue