mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-07-05 15:18:30 +00:00
-d: exclude non-directories
Adding flag, and supporting functionality for exluding entries that are non-directories Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
353436a031
commit
c0a5cb25ec
7 changed files with 117 additions and 15 deletions
17
walk_test.go
17
walk_test.go
|
@ -35,3 +35,20 @@ func TestWalk(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWalkDirectory(t *testing.T) {
|
||||
dh, err := Walk(".", []ExcludeFunc{ExcludeNonDirectories}, []Keyword{"type"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for i := range dh.Entries {
|
||||
for _, keyval := range dh.Entries[i].AllKeys() {
|
||||
if dh.Entries[i].Type == FullType || dh.Entries[i].Type == RelativeType {
|
||||
if keyval.Keyword() == "type" && keyval.Value() != "dir" {
|
||||
t.Errorf("expected only directories, but %q is a %q", dh.Entries[i].Name, keyval.Value())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue