1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-25 22:12:38 +02:00

Improve tests (#18)

* Use subtests

* Make unexported-return type check
This commit is contained in:
Tamir Duberstein
2018-06-11 14:22:06 -04:00
committed by Minko Gechev
parent fb3c2d09af
commit 1b2ffe282e
2 changed files with 18 additions and 14 deletions

View File

@@ -7,9 +7,8 @@ import (
"regexp"
"testing"
"github.com/mgechev/revive/rule"
"github.com/mgechev/revive/lint"
"github.com/mgechev/revive/rule"
)
var lintMatch = flag.String("lint.match", "", "restrict fixtures matches to this pattern")
@@ -55,16 +54,15 @@ func TestAll(t *testing.T) {
if !rx.MatchString(fi.Name()) {
continue
}
//t.Logf("Testing %s", fi.Name())
src, err := ioutil.ReadFile(path.Join(baseDir, fi.Name()))
if err != nil {
t.Fatalf("Failed reading %s: %v", fi.Name(), err)
}
t.Run(fi.Name(), func(t *testing.T) {
src, err := ioutil.ReadFile(path.Join(baseDir, fi.Name()))
if err != nil {
t.Fatalf("Failed reading %s: %v", fi.Name(), err)
}
err = assertFailures(t, baseDir, fi, src, rules, map[string]lint.RuleConfig{})
if err != nil {
t.Errorf("Linting %s: %v", fi.Name(), err)
continue
}
if err := assertFailures(t, baseDir, fi, src, rules, map[string]lint.RuleConfig{}); err != nil {
t.Errorf("Linting %s: %v", fi.Name(), err)
}
})
}
}