Skip to content

Commit 98b44f0

Browse files
committed
test: add unmarshal UUID test
1 parent a5a0e2f commit 98b44f0

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/bsm/gomega v1.27.10
88
github.com/cespare/xxhash/v2 v2.2.0
99
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
10+
github.com/google/uuid v1.6.0
1011
)
1112

1213
retract (

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj
66
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
77
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
88
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
9+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
10+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=

internal/hscan/hscan_test.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
. "github.com/bsm/ginkgo/v2"
1010
. "github.com/bsm/gomega"
11-
11+
"github.com/google/uuid"
1212
"github.com/redis/go-redis/v9/internal/util"
1313
)
1414

@@ -48,6 +48,10 @@ type TimeData struct {
4848
Time *TimeRFC3339Nano `redis:"login"`
4949
}
5050

51+
type UUIDData struct {
52+
ID uuid.UUID `redis:"id"`
53+
}
54+
5155
type i []interface{}
5256

5357
func TestGinkgoSuite(t *testing.T) {
@@ -217,4 +221,13 @@ var _ = Describe("Scan", func() {
217221
Expect(Scan(&tt, i{"time"}, i{now.Format(time.RFC3339Nano)})).NotTo(HaveOccurred())
218222
Expect(now.Unix()).To(Equal(tt.Time.Unix()))
219223
})
224+
225+
It("should unmarshal UUID", func() {
226+
var ud UUIDData
227+
228+
testUUID := uuid.New()
229+
230+
Expect(Scan(&ud, i{"id"}, i{testUUID.String()})).NotTo(HaveOccurred())
231+
Expect(ud.ID).To(Equal(testUUID))
232+
})
220233
})

0 commit comments

Comments
 (0)