Skip to content

Commit

Permalink
review: use new test framework
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Aug 21, 2022
1 parent c45b986 commit 9406328
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions test/linters_test.go
Expand Up @@ -118,6 +118,14 @@ func findSources(t *testing.T, pathPatterns ...string) []string {
return sources
}

func TestLogrLint(t *testing.T) {
testSourcesFromDir(t, filepath.Join(testdataDir, "logrlint"))
func TestSourcesFromTestdataSubDir(t *testing.T) {
subDirs := []string{
"logrlint",
}

for _, dir := range subDirs {
t.Run(dir, func(t *testing.T) {
testSourcesFromDir(t, filepath.Join(testdataDir, dir))
})
}
}
Expand Up @@ -9,8 +9,8 @@ import (

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

0 comments on commit 9406328

Please sign in to comment.