Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests: add os test
  • Loading branch information
rymut committed Dec 20, 2024
commit 6cdce09862293ac6aaf2873353d0587c83db2299
18 changes: 1 addition & 17 deletions tpl/os/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,7 @@ func (ns *Namespace) ReadDir(i any, mode ...any) ([]_os.FileInfo, error) {
if (old) {
list, err = afero.ReadDir(ns.workFs, path)
} else {
file, _ := ns.mountsFs.Open(path)
switch item := file.(type) {
case hugofs.DirOnlyOps: // fully virtual directory // hugofs.rootMappingDir
items, _ := item.Readdirnames(0)
list = make([]_os.FileInfo, len(items))
for i, item := range items {
file, _ := ns.mountsFs.Stat(path + "/" + item)
list[i] = file
}
case *overlayfs.Dir:
list, err = item.Readdir(0)
default:
//list, err = afero.ReadDir(ns.mountsFs, path)
}
if file != nil {
file.Close()
}
list, err = afero.ReadDir(ns.mountsFs, path)
}
if err != nil {
return nil, fmt.Errorf("failed to read directory %q: %s", path, err)
Expand Down
3 changes: 2 additions & 1 deletion tpl/os/os_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ l2
).Build()

b.AssertFileContent("public/index.html", `
START:|config.toml|myproject.txt|:END:
START:|assets|files|hugo.toml|layouts|myproject.txt|themes|:END:
`)
b.AssertFileContent("public/index.html", `START:||:END`)
}