mirror of
https://github.com/mgechev/revive.git
synced 2025-05-19 22:03:20 +02:00
* rule: tests for Configure with named options; fix errors * rule: refactor and add tests for ifelse rules * rule: allow lowercased and kebab-cased options * test: update integration tests with lowercased params * docs: update rules descriptions * rule: simplify Configure implementation with one option * gofmt and fix lint * review: add isRuleOption, update grammar in doc, simplify regex Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com> --------- Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mgechev/revive/lint"
|
|
"github.com/mgechev/revive/rule"
|
|
)
|
|
|
|
func TestImportAliasNaming(t *testing.T) {
|
|
testRule(t, "import_alias_naming", &rule.ImportAliasNamingRule{})
|
|
testRule(t, "import_alias_naming", &rule.ImportAliasNamingRule{}, &lint.RuleConfig{
|
|
Arguments: lint.Arguments{
|
|
map[string]any{},
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestImportAliasNaming_CustomConfig(t *testing.T) {
|
|
testRule(t, "import_alias_naming_custom_config", &rule.ImportAliasNamingRule{}, &lint.RuleConfig{
|
|
Arguments: []any{`^[a-z]+$`},
|
|
})
|
|
}
|
|
|
|
func TestImportAliasNaming_CustomConfigWithMultipleRules(t *testing.T) {
|
|
testRule(t, "import_alias_naming_custom_config_with_multiple_values", &rule.ImportAliasNamingRule{}, &lint.RuleConfig{
|
|
Arguments: []any{
|
|
map[string]any{
|
|
"allowRegex": `^[a-z][a-z0-9]*$`,
|
|
"denyRegex": `^((v\d+)|(v\d+alpha\d+))$`,
|
|
},
|
|
},
|
|
})
|
|
testRule(t, "import_alias_naming_custom_config_with_multiple_values", &rule.ImportAliasNamingRule{}, &lint.RuleConfig{
|
|
Arguments: []any{
|
|
map[string]any{
|
|
"allow-regex": `^[a-z][a-z0-9]*$`,
|
|
"deny-regex": `^((v\d+)|(v\d+alpha\d+))$`,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestImportAliasNaming_CustomConfigWithOnlyDeny(t *testing.T) {
|
|
testRule(t, "import_alias_naming_custom_config_with_only_deny", &rule.ImportAliasNamingRule{}, &lint.RuleConfig{
|
|
Arguments: []any{
|
|
map[string]any{
|
|
"denyRegex": `^((v\d+)|(v\d+alpha\d+))$`,
|
|
},
|
|
},
|
|
})
|
|
}
|