golangci-lint/pkg/result/processors/processor_test.go
Ryan Currah fa7adcbda9
add ability to set issue severity (#1155)
* add ability to set issue severity for out formats that support it based on severity rules

* fix lint issues

* change log child name

* code climate omit severity if empty

* add tests for severity rules, add support for case sensitive rules, fix lint issues, better doc comments, share processor test

* deduplicated rule logic into a base rule that can be used by multiple rule types, moved severity config to it's own parent key named severity, reduced size of NewRunner function to make it easier to read

* put validate function under base rule struct

* better validation error wording

* add Fingerprint and Description methods to Issue struct, made codeclimate reporter easier to read, checkstyle output is now pretty printed
2020-05-25 08:21:42 -04:00

52 lines
1.0 KiB
Go

package processors
import (
"go/token"
"testing"
"github.com/golangci/golangci-lint/pkg/result"
"github.com/stretchr/testify/assert"
)
type issueTestCase struct {
Path string
Line int
Text string
Linter string
Severity string
}
func newIssueFromIssueTestCase(c issueTestCase) result.Issue {
return result.Issue{
Text: c.Text,
FromLinter: c.Linter,
Pos: token.Position{
Filename: c.Path,
Line: c.Line,
},
}
}
func newIssueFromTextTestCase(text string) result.Issue {
return result.Issue{
Text: text,
}
}
func process(t *testing.T, p Processor, issues ...result.Issue) []result.Issue {
processedIssues, err := p.Process(issues)
assert.NoError(t, err)
return processedIssues
}
func processAssertSame(t *testing.T, p Processor, issues ...result.Issue) {
processedIssues := process(t, p, issues...)
assert.Equal(t, issues, processedIssues)
}
func processAssertEmpty(t *testing.T, p Processor, issues ...result.Issue) {
processedIssues := process(t, p, issues...)
assert.Empty(t, processedIssues)
}