Implement TextUnmarshaller interface for Level type

Since the implementation of the TextMarshaller interface
we could not unmarshal previously json marshalled Level value.
Fixes #873
This commit is contained in:
David Bariod
2018-12-26 17:43:14 +01:00
parent 2067ea4241
commit ff695daa36
3 changed files with 87 additions and 30 deletions
-13
View File
@@ -508,19 +508,6 @@ 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++ {