From c92ea59228fba7f950db681de353b6203e04507d Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Fri, 15 Oct 2021 16:07:38 +0800 Subject: [PATCH] test: add more tests (#1137) --- core/jsontype/time_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/jsontype/time_test.go b/core/jsontype/time_test.go index 5d675fea..b1714e08 100644 --- a/core/jsontype/time_test.go +++ b/core/jsontype/time_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + "github.com/globalsign/mgo/bson" "github.com/stretchr/testify/assert" ) @@ -106,3 +107,20 @@ func TestMilliTime_UnmarshalJSON(t *testing.T) { }) } } + +func TestUnmarshalWithError(t *testing.T) { + var mt MilliTime + assert.NotNil(t, mt.UnmarshalJSON([]byte("hello"))) +} + +func TestSetBSON(t *testing.T) { + data, err := bson.Marshal(time.Now()) + assert.Nil(t, err) + + var raw bson.Raw + assert.Nil(t, bson.Unmarshal(data, &raw)) + + var mt MilliTime + assert.Nil(t, mt.SetBSON(raw)) + assert.NotNil(t, mt.SetBSON(bson.Raw{})) +}