package pkgtest import ( "io/ioutil" "net/http" "net/http/httptest" "os" "path/filepath" "testing" "github.com/markbates/pkger/pkging" "github.com/markbates/pkger/pkging/pkgutil" "github.com/stretchr/testify/require" ) // ├── main.go // ├── public // │   ├── images // │   │   ├── mark.png // │   └── index.html // └── templates // ├── a.txt // └── b // └── b.txt var folderFiles = []string{ "/main.go", "/public/images/mark.png", "/public/index.html", "/templates/a.txt", "/templates/b/b.txt", } func (s Suite) WriteFolder(path string) error { for _, f := range folderFiles { f = filepath.Join(path, f) if err := os.MkdirAll(filepath.Dir(f), 0755); err != nil { return err } if err := ioutil.WriteFile(f, []byte("!"+f), 0644); err != nil { return err } } return nil } func (s Suite) LoadFolder(pkg pkging.Pkger) error { for _, f := range folderFiles { if err := pkg.MkdirAll(filepath.Dir(f), 0755); err != nil { return err } if err := pkgutil.WriteFile(pkg, f, []byte("!"+f), 0644); err != nil { return err } } return nil } func (s Suite) Test_HTTP_Dir(t *testing.T) { r := require.New(t) pkg, err := s.Make() r.NoError(err) cur, err := pkg.Current() r.NoError(err) ip := cur.ImportPath table := []struct { in string req string exp string }{ {in: "/", req: "/", exp: `>public/public/public//mark.png`) // r.NotContains(string(b), `/public`) // r.NotContains(string(b), `/images`) // r.NotContains(string(b), `/go.mod`) // }