1
0
mirror of https://github.com/mgechev/revive.git synced 2024-12-02 09:02:23 +02:00
revive/test/import_alias_naming_test.go
2024-11-11 19:31:18 +01:00

45 lines
1.1 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+))$`,
},
},
})
}
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+))$`,
},
},
})
}