Skip to content

Commit b45b8a9

Browse files
committed
test: Minor nits
- We can use backticks to avoid having to escape quotes - Prefer to have the error and non-error paths branch so that we're not asserting the value of level in the error case (since that's specifically not part of the contract)
1 parent 6dca8e8 commit b45b8a9

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

zapcore/level_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ package zapcore
2323
import (
2424
"bytes"
2525
"flag"
26-
"fmt"
2726
"strings"
2827
"testing"
2928

@@ -81,16 +80,21 @@ func TestParseLevel(t *testing.T) {
8180
tests := []struct {
8281
text string
8382
level Level
84-
err error
83+
err string
8584
}{
86-
{"info", InfoLevel, nil},
87-
{"DEBUG", DebugLevel, nil},
88-
{"FOO", 0, fmt.Errorf("unrecognized level: \"FOO\"")},
85+
{"info", InfoLevel, ""},
86+
{"DEBUG", DebugLevel, ""},
87+
{"FOO", 0, `unrecognized level: "FOO"`},
8988
}
9089
for _, tt := range tests {
9190
parsedLevel, err := ParseLevel(tt.text)
92-
assert.Equal(t, tt.level, parsedLevel)
93-
assert.Equal(t, tt.err, err)
91+
if len(tt.err) == 0 {
92+
assert.NoError(t, err)
93+
assert.Equal(t, tt.level, parsedLevel)
94+
} else {
95+
assert.Error(t, err)
96+
assert.Contains(t, err.Error(), tt.err)
97+
}
9498
}
9599
}
96100

0 commit comments

Comments
 (0)