Skip to content

Commit

Permalink
revert blacklist test and testdata
Browse files Browse the repository at this point in the history
  • Loading branch information
mfederowicz committed Dec 14, 2023
1 parent 66e1d2a commit 9d73a9f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/import-blacklist_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package test

import (
"testing"

"github.com/mgechev/revive/lint"
"github.com/mgechev/revive/rule"
)

func TestImportsBlacklistOriginal(t *testing.T) {
args := []any{"crypto/md5", "crypto/sha1"}

testRule(t, "imports-blacklist-original", &rule.ImportsBlacklistRule{}, &lint.RuleConfig{
Arguments: args,
})
}

func TestImportsBlacklist(t *testing.T) {
args := []any{"github.com/full/match", "wildcard/**/between", "wildcard/backward/**", "**/wildcard/forward", "full"}

testRule(t, "imports-blacklist", &rule.ImportsBlacklistRule{}, &lint.RuleConfig{
Arguments: args,
})
}

func BenchmarkImportsBlacklist(b *testing.B) {
args := []any{"github.com/full/match", "wildcard/**/between", "wildcard/backward/**", "**/wildcard/forward", "full"}
var t *testing.T
for i := 0; i <= b.N; i++ {
testRule(t, "imports-blacklist", &rule.ImportsBlacklistRule{}, &lint.RuleConfig{
Arguments: args,
})
}
}
8 changes: 8 additions & 0 deletions testdata/imports-blacklist-original.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fixtures

import (
"crypto/md5" // MATCH /should not use the following blacklisted import: "crypto/md5"/
"crypto/sha1" // MATCH /should not use the following blacklisted import: "crypto/sha1"/
"strings"
)

0 comments on commit 9d73a9f

Please sign in to comment.