@@ -10,6 +10,7 @@ import (
10
10
"bytes"
11
11
"io"
12
12
"testing"
13
+ "time"
13
14
14
15
"github.com/google/go-cmp/cmp"
15
16
"github.com/mongodb/mongo-go-driver/bson/objectid"
@@ -360,6 +361,7 @@ func reflectionEncoderTest(t *testing.T) {
360
361
oids := []objectid.ObjectID {objectid .New (), objectid .New (), objectid .New ()}
361
362
var str = new (string )
362
363
* str = "bar"
364
+ now := time .Now ()
363
365
364
366
testCases := []struct {
365
367
name string
@@ -738,6 +740,7 @@ func reflectionEncoderTest(t *testing.T) {
738
740
V _Interface
739
741
W map [struct {}]struct {}
740
742
X map [struct {}]struct {}
743
+ Z time.Time
741
744
}{
742
745
A : true ,
743
746
B : 123 ,
@@ -766,6 +769,7 @@ func reflectionEncoderTest(t *testing.T) {
766
769
V : _Interface ((* _impl )(nil )), // typed nil
767
770
W : map [struct {}]struct {}{},
768
771
X : nil ,
772
+ Z : now ,
769
773
},
770
774
docToBytes (NewDocument (
771
775
EC .Boolean ("a" , true ),
@@ -791,6 +795,7 @@ func reflectionEncoderTest(t *testing.T) {
791
795
EC .Null ("v" ),
792
796
EC .SubDocument ("w" , NewDocument ()),
793
797
EC .Null ("x" ),
798
+ EC .DateTime ("z" , now .UnixNano ()/ int64 (time .Millisecond )),
794
799
)),
795
800
nil ,
796
801
},
@@ -823,6 +828,7 @@ func reflectionEncoderTest(t *testing.T) {
823
828
W []map [struct {}]struct {}
824
829
X []map [struct {}]struct {}
825
830
Y []map [struct {}]struct {}
831
+ Z []time.Time
826
832
}{
827
833
A : []bool {true },
828
834
B : []int32 {123 },
@@ -854,6 +860,7 @@ func reflectionEncoderTest(t *testing.T) {
854
860
W : nil ,
855
861
X : []map [struct {}]struct {}{}, // Should be empty BSON Array
856
862
Y : []map [struct {}]struct {}{{}}, // Should be BSON array with one element, an empty BSON SubDocument
863
+ Z : []time.Time {now , now },
857
864
},
858
865
docToBytes (NewDocument (
859
866
EC .ArrayFromElements ("a" , VC .Boolean (true )),
@@ -880,6 +887,7 @@ func reflectionEncoderTest(t *testing.T) {
880
887
EC .Null ("w" ),
881
888
EC .Array ("x" , NewArray ()),
882
889
EC .ArrayFromElements ("y" , VC .Document (NewDocument ())),
890
+ EC .ArrayFromElements ("z" , VC .DateTime (now .UnixNano ()/ int64 (time .Millisecond )), VC .DateTime (now .UnixNano ()/ int64 (time .Millisecond ))),
883
891
)),
884
892
nil ,
885
893
},
0 commit comments