add new test case for walk.go

- hidden directories and files should be ignored
- if the notebook root folder is hidden, this is accepted
pull/402/head
tjex 2 months ago
parent dadb96726e
commit a9c5e8c88d

@ -0,0 +1 @@
this is a hidden file, and should not be indexed / walked.

@ -16,7 +16,36 @@ func TestWalk(t *testing.T) {
return filepath.Ext(path) != ".md", nil
}
notebookRoot := filepath.Base(path)
notebookRoot := filepath.Base(path)
actual := make([]string, 0)
for m := range Walk(path, &util.NullLogger, notebookRoot, shouldIgnore) {
assert.NotNil(t, m.Modified)
actual = append(actual, m.Path)
}
assert.Equal(t, actual, []string{
"Dir3/a.md",
"a.md",
"b.md",
"dir1/a.md",
"dir1/b.md",
"dir1/dir1/a.md",
"dir1 a space/a.md",
"dir2/a.md",
})
}
// Walk should ignore all hidden files and dirs (prefixed with "."), with
// exception of the notebook's root dir; i.e the root dir is allowed to be
// hidden.
func TestWalkHidden(t *testing.T) {
var path = fixtures.Path(".walk-hidden")
shouldIgnore := func(path string) (bool, error) {
return filepath.Ext(path) != ".md", nil
}
notebookRoot := filepath.Base(path)
actual := make([]string, 0)
for m := range Walk(path, &util.NullLogger, notebookRoot, shouldIgnore) {
assert.NotNil(t, m.Modified)

Loading…
Cancel
Save