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