Increase test coverage

This commit is contained in:
Julian Kornberger 2016-03-21 23:02:39 +01:00
parent 00da215efc
commit c815ff5058
1 changed files with 12 additions and 1 deletions

View File

@ -28,11 +28,22 @@ func TestMarshalTime(t *testing.T) {
assert.Equal(`"2012-11-01T22:08:41"`, string(json))
}
func TestUnmarshalTime(t *testing.T) {
func TestUnmarshalValidTime(t *testing.T) {
assert := assert.New(t)
jsonTime := Time{}
// valid time
err := jsonTime.UnmarshalJSON([]byte(`"2012-11-01T22:08:41"`))
assert.Nil(err)
assert.False(jsonTime.IsZero())
}
func TestUnmarshalInvalidTime(t *testing.T) {
assert := assert.New(t)
jsonTime := Time{}
// invalid time
err := jsonTime.UnmarshalJSON([]byte(`1458597472`))
assert.EqualError(err, "invalid jsontime")
assert.True(jsonTime.IsZero())
}