test the error to ensure there isn't an unexpected error in the test

This commit is contained in:
Edward Muller
2019-10-13 17:45:01 -07:00
parent f9951ccddd
commit 46015a925f
3 changed files with 14 additions and 5 deletions
+6 -2
View File
@@ -21,7 +21,9 @@ func TestFieldValueError(t *testing.T) {
l.WithField("func", func() {}).Info("test")
fmt.Println(buf.String())
var data map[string]interface{}
json.Unmarshal(buf.Bytes(), &data)
if err := json.Unmarshal(buf.Bytes(), &data); err != nil {
t.Error("unexpected error", err)
}
_, ok := data[FieldKeyLogrusError]
require.True(t, ok)
}
@@ -37,7 +39,9 @@ func TestNoFieldValueError(t *testing.T) {
l.WithField("str", "str").Info("test")
fmt.Println(buf.String())
var data map[string]interface{}
json.Unmarshal(buf.Bytes(), &data)
if err := json.Unmarshal(buf.Bytes(), &data); err != nil {
t.Error("unexpected error", err)
}
_, ok := data[FieldKeyLogrusError]
require.False(t, ok)
}