Add config file finder.
This commit is contained in:
34
editorconfig/config_file_finder_test.go
Normal file
34
editorconfig/config_file_finder_test.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package editorconfig
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetConfigFilePathInDirectoryForNonRootPath(t *testing.T) {
|
||||
if GetConfigFilePathInDirectory("/home/x") != "/home/x/.editorconfig" {
|
||||
t.Error("GetConfigFilePathInDirectory failed for path /home/x")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetConfigFilePathInDirectoryForRootPath(t *testing.T) {
|
||||
if GetConfigFilePathInDirectory("/") != "/.editorconfig" {
|
||||
t.Error("GetConfigFilePathInDirectory failed for path /")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindConfigFilesWhenDirectoryHasRootConfig(t *testing.T) {
|
||||
files := FindConfigFiles([]string{"tests/a/b/has-root-config/file.java"})
|
||||
|
||||
if len(files) != 1 {
|
||||
t.Error("Should have found 1 .editorconfig file but found " + strconv.Itoa(len(files)))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindConfigFilesFindsRootConfigInParentDirectory(t *testing.T) {
|
||||
files := FindConfigFiles([]string{"tests/a/b/c/d/file.java"})
|
||||
|
||||
if len(files) != 2 {
|
||||
t.Error("Should have found 2 .editorconfig files but found " + strconv.Itoa(len(files)))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user