1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-21 17:16:40 +02:00

refactor: simplify tests (#1089)

This commit is contained in:
Oleksandr Redko 2024-11-04 14:25:03 +02:00 committed by GitHub
parent 0fc9613257
commit 6228ba57cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 7 deletions

View File

@ -18,7 +18,7 @@ func TestReviveCreateInstance(t *testing.T) {
t.Fatal("Expected MaxOpenFiles to be 2048")
}
if revive.lintingRules == nil || len(revive.lintingRules) == 0 {
if len(revive.lintingRules) == 0 {
t.Fatal("Linting rules not loaded.")
}

View File

@ -40,9 +40,7 @@ func testRule(t *testing.T, filename string, rule lint.Rule, config ...*lint.Rul
}
func assertSuccess(t *testing.T, baseDir string, fi os.FileInfo, rules []lint.Rule, config map[string]lint.RuleConfig) error {
l := lint.New(func(file string) ([]byte, error) {
return os.ReadFile(file)
}, 0)
l := lint.New(os.ReadFile, 0)
filePath := filepath.Join(baseDir, fi.Name())
ps, err := l.Lint([][]string{{filePath}}, rules, lint.Config{
@ -63,9 +61,7 @@ func assertSuccess(t *testing.T, baseDir string, fi os.FileInfo, rules []lint.Ru
}
func assertFailures(t *testing.T, baseDir string, fi os.FileInfo, src []byte, rules []lint.Rule, config map[string]lint.RuleConfig) error {
l := lint.New(func(file string) ([]byte, error) {
return os.ReadFile(file)
}, 0)
l := lint.New(os.ReadFile, 0)
ins := parseInstructions(t, filepath.Join(baseDir, fi.Name()), src)
if ins == nil {