mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 13:32:24 +00:00
Merge pull request #127 from setekhid/master
make IsDotFile do not treat '.' as true
This commit is contained in:
commit
91c074ea1d
4
utils.go
4
utils.go
@ -40,7 +40,9 @@ func IsConfiguration(path string) bool {
|
||||
|
||||
// IsDotFile returns whether or not path has dot as a prefix.
|
||||
func IsDotFile(path string) bool {
|
||||
return strings.HasPrefix(filepath.Base(path), ".")
|
||||
path = filepath.Clean(path)
|
||||
base := filepath.Base(path)
|
||||
return strings.HasPrefix(base, ".") && base != "." && base != ".."
|
||||
}
|
||||
|
||||
// IsVendor returns whether or not path is a vendor path.
|
||||
|
@ -82,6 +82,22 @@ func (s *EnryTestSuite) TestIsBinary() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EnryTestSuite) TestIsDotFile() {
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
expected bool
|
||||
}{
|
||||
{name: "TestIsDotFile_1", path: "foo/bar/./", expected: false},
|
||||
{name: "TestIsDotFile_2", path: "./", expected: false},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
is := IsDotFile(test.path)
|
||||
assert.Equal(s.T(), test.expected, is, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileCountListSort(t *testing.T) {
|
||||
sampleData := FileCountList{{"a", 8}, {"b", 65}, {"c", 20}, {"d", 90}}
|
||||
const ascending = "ASC"
|
||||
|
Loading…
Reference in New Issue
Block a user