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

fix: return configure rule error (#1193)

This commit is contained in:
Oleksandr Redko
2024-12-23 16:10:21 +02:00
committed by GitHub
parent 3d1115dacd
commit 7998011cac
3 changed files with 17 additions and 1 deletions

View File

@@ -88,6 +88,7 @@ func TestGetLintingRules(t *testing.T) {
tt := map[string]struct {
confPath string
wantRulesCount int
wantErr string
}{
"no rules": {
confPath: "testdata/noRules.toml",
@@ -105,6 +106,10 @@ func TestGetLintingRules(t *testing.T) {
confPath: "testdata/enable2.toml",
wantRulesCount: 2,
},
"var-naming configure error": {
confPath: "testdata/varNamingConfigureError.toml",
wantErr: `cannot configure rule: "var-naming": invalid argument to the var-naming rule. Expecting a allowlist of type slice with initialisms, got string`,
},
}
for name, tc := range tt {
@@ -114,6 +119,13 @@ func TestGetLintingRules(t *testing.T) {
t.Fatalf("Unexpected error while loading conf: %v", err)
}
rules, err := GetLintingRules(cfg, []lint.Rule{})
if tc.wantErr != "" {
if err == nil || err.Error() != tc.wantErr {
t.Fatalf("Expected error %q, got %q", tc.wantErr, err)
}
return
}
switch {
case err != nil:
t.Fatalf("Unexpected error\n\t%v", err)