github.com/elek/golangci-lint@v1.42.2-0.20211208090441-c05b7fcb3a9a/pkg/result/processors/uniq_by_line_test.go (about) 1 package processors 2 3 import ( 4 "go/token" 5 "testing" 6 7 "github.com/elek/golangci-lint/pkg/config" 8 "github.com/elek/golangci-lint/pkg/result" 9 ) 10 11 func newFLIssue(file string, line int) result.Issue { 12 return result.Issue{ 13 Pos: token.Position{ 14 Filename: file, 15 Line: line, 16 }, 17 } 18 } 19 20 func TestUniqByLine(t *testing.T) { 21 cfg := config.Config{} 22 cfg.Output.UniqByLine = true 23 24 p := NewUniqByLine(&cfg) 25 i1 := newFLIssue("f1", 1) 26 27 processAssertSame(t, p, i1) 28 processAssertEmpty(t, p, i1) // check skipping 29 processAssertEmpty(t, p, i1) // check accumulated error 30 31 processAssertSame(t, p, newFLIssue("f1", 2)) // another line 32 processAssertSame(t, p, newFLIssue("f2", 1)) // another file 33 } 34 35 func TestUniqByLineDisabled(t *testing.T) { 36 cfg := config.Config{} 37 cfg.Output.UniqByLine = false 38 39 p := NewUniqByLine(&cfg) 40 i1 := newFLIssue("f1", 1) 41 42 processAssertSame(t, p, i1) 43 processAssertSame(t, p, i1) // check the same issue passed twice 44 }