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