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
+5 -2
View File
@@ -656,11 +656,14 @@ func TestEntryWriter(t *testing.T) {
log := New()
log.Out = cw
log.Formatter = new(JSONFormatter)
log.WithField("foo", "bar").WriterLevel(WarnLevel).Write([]byte("hello\n"))
_, err := log.WithField("foo", "bar").WriterLevel(WarnLevel).Write([]byte("hello\n"))
if err != nil {
t.Error("unexecpted error", err)
}
bs := <-cw
var fields Fields
err := json.Unmarshal(bs, &fields)
err = json.Unmarshal(bs, &fields)
assert.Nil(t, err)
assert.Equal(t, fields["foo"], "bar")
assert.Equal(t, fields["level"], "warning")