|
|
|
@ -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{}))
|
|
|
|
|
}
|
|
|
|
|