mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-02 16:28:39 +08:00
test: add more tests (#1137)
This commit is contained in:
parent
afddfea093
commit
c92ea59228
@ -5,6 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/globalsign/mgo/bson"
|
||||||
"github.com/stretchr/testify/assert"
|
"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{}))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user