MCPcopy
hub / github.com/rs/zerolog / TestUnmarshalTextLevel

Function TestUnmarshalTextLevel

log_test.go:1404–1440  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1402}
1403
1404func TestUnmarshalTextLevel(t *testing.T) {
1405 type args struct {
1406 levelStr string
1407 }
1408 tests := []struct {
1409 name string
1410 args args
1411 want Level
1412 wantErr bool
1413 }{
1414 {"trace", args{"trace"}, TraceLevel, false},
1415 {"debug", args{"debug"}, DebugLevel, false},
1416 {"info", args{"info"}, InfoLevel, false},
1417 {"warn", args{"warn"}, WarnLevel, false},
1418 {"error", args{"error"}, ErrorLevel, false},
1419 {"fatal", args{"fatal"}, FatalLevel, false},
1420 {"panic", args{"panic"}, PanicLevel, false},
1421 {"disabled", args{"disabled"}, Disabled, false},
1422 {"nolevel", args{""}, NoLevel, false},
1423 {"-1", args{"-1"}, TraceLevel, false},
1424 {"-2", args{"-2"}, Level(-2), false},
1425 {"-3", args{"-3"}, Level(-3), false},
1426 }
1427 for _, tt := range tests {
1428 t.Run(tt.name, func(t *testing.T) {
1429 var l Level
1430 err := l.UnmarshalText([]byte(tt.args.levelStr))
1431 if (err != nil) != tt.wantErr {
1432 t.Errorf("UnmarshalText() error = %v, wantErr %v", err, tt.wantErr)
1433 return
1434 }
1435 if l != tt.want {
1436 t.Errorf("UnmarshalText() got = %v, want %v", l, tt.want)
1437 }
1438 })
1439 }
1440}
1441
1442func TestUnmarshalTextLevelNil(t *testing.T) {
1443 var l *Level

Callers

nothing calls this directly

Calls 3

UnmarshalTextMethod · 0.95
LevelTypeAlias · 0.70
RunMethod · 0.65

Tested by

no test coverage detected