Skip to content

Commit 9406328

Browse files
committed
review: use new test framework
1 parent c45b986 commit 9406328

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

test/linters_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ func findSources(t *testing.T, pathPatterns ...string) []string {
118118
return sources
119119
}
120120

121-
func TestLogrLint(t *testing.T) {
122-
testSourcesFromDir(t, filepath.Join(testdataDir, "logrlint"))
121+
func TestSourcesFromTestdataSubDir(t *testing.T) {
122+
subDirs := []string{
123+
"logrlint",
124+
}
125+
126+
for _, dir := range subDirs {
127+
t.Run(dir, func(t *testing.T) {
128+
testSourcesFromDir(t, filepath.Join(testdataDir, dir))
129+
})
130+
}
123131
}

test/testdata/logrlint/example.go renamed to test/testdata/logrlint/logrlint.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99

1010
func Example() {
1111
log := logr.Discard()
12-
log = log.WithValues("key") // Error `odd number of arguments passed as key-value pairs for logging`
13-
log.Info("message", "key1", "value1", "key2", "value2", "key3") // Error `odd number of arguments passed as key-value pairs for logging`
14-
log.Error(fmt.Errorf("error"), "message", "key1", "value1", "key2") // Error `odd number of arguments passed as key-value pairs for logging`
12+
log = log.WithValues("key") // want `odd number of arguments passed as key-value pairs for logging`
13+
log.Info("message", "key1", "value1", "key2", "value2", "key3") // want `odd number of arguments passed as key-value pairs for logging`
14+
log.Error(fmt.Errorf("error"), "message", "key1", "value1", "key2") // want `odd number of arguments passed as key-value pairs for logging`
1515
log.Error(fmt.Errorf("error"), "message", "key1", "value1", "key2", "value2")
1616
}

0 commit comments

Comments
 (0)