Add function GetRulesToApplyToSourcePath.

This commit is contained in:
Amy Boyd
2016-06-22 23:58:10 +01:00
parent cfc8de6801
commit 2a8ad5689c
4 changed files with 114 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
package editorconfig
import (
"testing"
)
func TestGetRulesToApplyToSourcePath(t *testing.T) {
result := GetRulesToApplyToSourcePath(
"tests/a/b/file.go",
[]ConfigFile{
CreateConfigFileStruct("tests/.editorconfig"),
},
)
if result["end_of_line"] != "lf" {
t.Error("The end_of_line rule should come from the * file pattern")
}
if result["indent_style"] != "tabs" {
t.Error("The indent_style rule should come from the **.go file pattern, overriding the *'s indent_style")
}
}
func TestGetRulesToApplyToSourcePathWhenNoRulesShouldApply(t *testing.T) {
result := GetRulesToApplyToSourcePath(
"some-file-not-affected-by-rules",
[]ConfigFile{
CreateConfigFileStruct("tests/.editorconfig"),
},
)
if len(result) != 0 {
t.Error("No rules should be applied for the file")
}
}