pkger/fs/fstest/fstest.go

43 lines
651 B
Go
Raw Normal View History

2019-09-01 05:45:22 +03:00
package fstest
import (
"path"
"github.com/markbates/pkger/fs"
)
func Files(fx fs.FileSystem) (TestFiles, error) {
tf := TestFiles{}
for _, f := range fileList {
2019-09-01 06:29:25 +03:00
pt, err := Path(fx, f)
if err != nil {
return tf, err
}
tf[pt] = TestFile{
Name: pt.Name,
Path: pt,
2019-09-01 05:45:22 +03:00
}
}
return tf, nil
}
2019-09-01 20:21:34 +03:00
func Path(fx fs.FileSystem, p string) (fs.Path, error) {
pt, err := fx.Parse(p)
if err != nil {
return pt, err
2019-09-01 06:29:25 +03:00
}
2019-09-01 20:21:34 +03:00
pt.Name = path.Join("/.fstest", pt.Name)
return pt, nil
2019-09-01 05:45:22 +03:00
}
var fileList = []string{
"/main.go",
"/go.mod",
"/go.sum",
"/public/index.html",
"/public/images/mark.png",
"/templates/a.txt",
"/templates/b/b.txt",
}