Adding upstream version 0.3.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
4da56737a9
commit
93a9a63b70
11 changed files with 438 additions and 0 deletions
35
levels_test.go
Normal file
35
levels_test.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package logr
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLevelFromString(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
input string
|
||||
expected Level
|
||||
expectedErr error
|
||||
}{
|
||||
{"DEBUG", LevelDebug, nil},
|
||||
{"debug", LevelDebug, nil},
|
||||
{"INFO", LevelInfo, nil},
|
||||
{"info", LevelInfo, nil},
|
||||
{"WARN", LevelWarn, nil},
|
||||
{"warn", LevelWarn, nil},
|
||||
{"ERROR", LevelError, nil},
|
||||
{"error", LevelError, nil},
|
||||
{"", LevelDebug, ErrInvalidLevelString},
|
||||
{"invalid", LevelDebug, ErrInvalidLevelString},
|
||||
}
|
||||
for _, scenario := range scenarios {
|
||||
t.Run(scenario.input, func(t *testing.T) {
|
||||
actual, err := LevelFromString(scenario.input)
|
||||
if actual != scenario.expected {
|
||||
t.Errorf("expected %s, got %s", scenario.expected, actual)
|
||||
}
|
||||
if err != scenario.expectedErr {
|
||||
t.Errorf("expected %v, got %v", scenario.expectedErr, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue