2013-09-05 01:28:59 -04:00
|
|
|
package source
|
2013-08-12 19:10:38 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2014-04-14 17:25:54 -04:00
|
|
|
func TestIgnoreDotFilesAndDirectories(t *testing.T) {
|
2013-08-12 19:10:38 -04:00
|
|
|
tests := []struct {
|
2013-08-23 17:40:02 -04:00
|
|
|
path string
|
2013-08-12 19:10:38 -04:00
|
|
|
ignore bool
|
2013-08-23 17:40:02 -04:00
|
|
|
}{
|
2015-03-05 17:19:10 -05:00
|
|
|
{".foobar/", true},
|
|
|
|
{"foobar/.barfoo/", true},
|
2013-08-12 19:10:38 -04:00
|
|
|
{"barfoo.md", false},
|
|
|
|
{"foobar/barfoo.md", false},
|
|
|
|
{"foobar/.barfoo.md", true},
|
|
|
|
{".barfoo.md", true},
|
|
|
|
{".md", true},
|
|
|
|
{"", true},
|
2014-02-28 23:18:06 -05:00
|
|
|
{"foobar/barfoo.md~", true},
|
|
|
|
{".foobar/barfoo.md~", true},
|
|
|
|
{"foobar~/barfoo.md", false},
|
|
|
|
{"foobar/bar~foo.md", false},
|
2013-08-12 19:10:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
2014-04-14 17:25:54 -04:00
|
|
|
if ignored := isNonProcessablePath(test.path); test.ignore != ignored {
|
2013-08-12 19:10:38 -04:00
|
|
|
t.Errorf("File not ignored. Expected: %t, got: %t", test.ignore, ignored)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|