diff options
Diffstat (limited to 'internal/recordsdir/recordsdir_test.go')
| -rw-r--r-- | internal/recordsdir/recordsdir_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/recordsdir/recordsdir_test.go b/internal/recordsdir/recordsdir_test.go index bee8d67..5e72d9d 100644 --- a/internal/recordsdir/recordsdir_test.go +++ b/internal/recordsdir/recordsdir_test.go @@ -4,6 +4,7 @@ import ( "os" "path/filepath" "testing" + "testing/fstest" ) func TestHostFromFileName(t *testing.T) { @@ -56,3 +57,18 @@ func TestListNonEmptyFiles_ReadError(t *testing.T) { t.Fatal("expected error") } } + +func TestListNonEmptyFilesFS_MapFS(t *testing.T) { + m := fstest.MapFS{ + "skip.txt": &fstest.MapFile{Data: []byte("x"), Mode: 0o644}, + "empty.records": &fstest.MapFile{Data: nil, Mode: 0o644}, + "h1.records": &fstest.MapFile{Data: []byte("line\n"), Mode: 0o644}, + } + entries, err := ListNonEmptyFilesFS(m, ".") + if err != nil { + t.Fatal(err) + } + if len(entries) != 1 || entries[0].Host != "h1" || entries[0].Path != "h1.records" { + t.Fatalf("got %#v", entries) + } +} |
