Merge pull request #845 from yanana/make-level-implement-text-unmarshaler

Make logrus.Level implement encoding.TextUnmarshaler
This commit is contained in:
David Bariod
2018-10-29 07:08:39 +01:00
committed by GitHub
2 changed files with 25 additions and 0 deletions
+13
View File
@@ -508,6 +508,19 @@ func TestParseLevel(t *testing.T) {
assert.Equal(t, "not a valid logrus Level: \"invalid\"", err.Error())
}
func TestUnmarshalText(t *testing.T) {
var u Level
for _, level := range AllLevels {
t.Run(level.String(), func(t *testing.T) {
assert.NoError(t, u.UnmarshalText([]byte(level.String())))
assert.Equal(t, level, u)
})
}
t.Run("invalid", func(t *testing.T) {
assert.Error(t, u.UnmarshalText([]byte("invalid")))
})
}
func TestGetSetLevelRace(t *testing.T) {
wg := sync.WaitGroup{}
for i := 0; i < 100; i++ {