Skip to content

Commit 0a66284

Browse files
committed
Adds time struct encoding unit test.
1 parent b72c904 commit 0a66284

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

bson/encode_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"bytes"
1111
"io"
1212
"testing"
13+
"time"
1314

1415
"github.com/google/go-cmp/cmp"
1516
"github.com/mongodb/mongo-go-driver/bson/objectid"
@@ -823,6 +824,7 @@ func reflectionEncoderTest(t *testing.T) {
823824
W []map[struct{}]struct{}
824825
X []map[struct{}]struct{}
825826
Y []map[struct{}]struct{}
827+
Z time.Time
826828
}{
827829
A: []bool{true},
828830
B: []int32{123},
@@ -854,6 +856,7 @@ func reflectionEncoderTest(t *testing.T) {
854856
W: nil,
855857
X: []map[struct{}]struct{}{}, // Should be empty BSON Array
856858
Y: []map[struct{}]struct{}{{}}, // Should be BSON array with one element, an empty BSON SubDocument
859+
Z: time.Now(),
857860
},
858861
docToBytes(NewDocument(
859862
EC.ArrayFromElements("a", VC.Boolean(true)),
@@ -880,6 +883,7 @@ func reflectionEncoderTest(t *testing.T) {
880883
EC.Null("w"),
881884
EC.Array("x", NewArray()),
882885
EC.ArrayFromElements("y", VC.Document(NewDocument())),
886+
EC.DateTime("z", time.Now().UnixNano()/int64(time.Millisecond)),
883887
)),
884888
nil,
885889
},

0 commit comments

Comments
 (0)