Skip to content

Commit

Permalink
refactor: simplify tests (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear authored Nov 4, 2024
1 parent 0fc9613 commit 6228ba5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion revivelib/core_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}

Expand Down
8 changes: 2 additions & 6 deletions test/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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 {
Expand Down

0 comments on commit 6228ba5

Please sign in to comment.