Skip to content

Commit

Permalink
Add error test for time
Browse files Browse the repository at this point in the history
  • Loading branch information
minodisk committed Feb 2, 2016
1 parent cd4752e commit fefeef1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions model/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ func TestTime_UnmarshalJSON(t *testing.T) {
}
}

func TestTime_UnmarshalJSONWithNonString(t *testing.T) {
s := `true`
var at model.Time
err := json.Unmarshal([]byte(s), &at)
if err == nil {
t.Errorf("error should occur")
}
}

func TestTime_UnmarshalJSONWithWrongFormat(t *testing.T) {
s := `"2016/02/03T13:05:06+09:00"`
var at model.Time
err := json.Unmarshal([]byte(s), &at)
if err == nil {
t.Errorf("error should occur")
}
}

func TestTime_MarshalYAML(t *testing.T) {
at := model.Time{time.Date(2016, 2, 3, 4, 5, 6, 0, time.UTC)}
b, err := yaml.Marshal(at)
Expand Down

0 comments on commit fefeef1

Please sign in to comment.