move the testing app
|
@ -43,7 +43,7 @@ func main() {
|
||||||
// : - seperator between the module/package name, pkg, and the "file path"
|
// : - seperator between the module/package name, pkg, and the "file path"
|
||||||
// path - this is the ABSOLUTE path to the file/directory you want, as relative
|
// path - this is the ABSOLUTE path to the file/directory you want, as relative
|
||||||
// to the root of the module/package's go.mod file.
|
// to the root of the module/package's go.mod file.
|
||||||
dir, err := pkger.Open("github.com/markbates/pkger/examples/app:/public")
|
dir, err := pkger.Open("github.com/markbates/pkger/internal/testdata/app:/public")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
Before Width: | Height: | Size: 634 KiB After Width: | Height: | Size: 634 KiB |
Before Width: | Height: | Size: 48 MiB After Width: | Height: | Size: 48 MiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
|
@ -16,15 +16,17 @@ func Test_Parser_App(t *testing.T) {
|
||||||
pwd, err := os.Getwd()
|
pwd, err := os.Getwd()
|
||||||
r.NoError(err)
|
r.NoError(err)
|
||||||
|
|
||||||
ch := filepath.Join(pwd, "..",
|
ch := filepath.Join(pwd,
|
||||||
"examples",
|
"..",
|
||||||
|
"internal",
|
||||||
|
"testdata",
|
||||||
"app")
|
"app")
|
||||||
|
|
||||||
os.RemoveAll(filepath.Join(ch, "pkged.go"))
|
os.RemoveAll(filepath.Join(ch, "pkged.go"))
|
||||||
|
|
||||||
info := here.Info{
|
info := here.Info{
|
||||||
Dir: ch,
|
Dir: ch,
|
||||||
ImportPath: "github.com/markbates/pkger/examples/app",
|
ImportPath: "github.com/markbates/pkger/internal/testdata/app",
|
||||||
}
|
}
|
||||||
here.Cache(info.ImportPath, func(s string) (here.Info, error) {
|
here.Cache(info.ImportPath, func(s string) (here.Info, error) {
|
||||||
return info, nil
|
return info, nil
|
||||||
|
@ -81,12 +83,12 @@ var inbed = []string{
|
||||||
"github.com/gobuffalo/buffalo:/render/template_test.go",
|
"github.com/gobuffalo/buffalo:/render/template_test.go",
|
||||||
"github.com/gobuffalo/buffalo:/render/xml.go",
|
"github.com/gobuffalo/buffalo:/render/xml.go",
|
||||||
"github.com/gobuffalo/buffalo:/render/xml_test.go",
|
"github.com/gobuffalo/buffalo:/render/xml_test.go",
|
||||||
"github.com/markbates/pkger/examples/app:/",
|
"github.com/markbates/pkger/internal/testdata/app:/",
|
||||||
"github.com/markbates/pkger/examples/app:/public",
|
"github.com/markbates/pkger/internal/testdata/app:/public",
|
||||||
"github.com/markbates/pkger/examples/app:/public/images",
|
"github.com/markbates/pkger/internal/testdata/app:/public/images",
|
||||||
"github.com/markbates/pkger/examples/app:/public/images/mark-small.png",
|
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark-small.png",
|
||||||
"github.com/markbates/pkger/examples/app:/public/images/mark.png",
|
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark.png",
|
||||||
"github.com/markbates/pkger/examples/app:/public/images/mark_250px.png",
|
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark_250px.png",
|
||||||
"github.com/markbates/pkger/examples/app:/public/images/mark_400px.png",
|
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark_400px.png",
|
||||||
"github.com/markbates/pkger/examples/app:/public/index.html",
|
"github.com/markbates/pkger/internal/testdata/app:/public/index.html",
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ func Test_Walk(t *testing.T) {
|
||||||
r := require.New(t)
|
r := require.New(t)
|
||||||
|
|
||||||
files := map[string]os.FileInfo{}
|
files := map[string]os.FileInfo{}
|
||||||
err := Walk("/examples/app", func(path string, info os.FileInfo, err error) error {
|
err := Walk("/internal/testdata/app", func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,16 @@ func Test_Pkger_Embedding(t *testing.T) {
|
||||||
pwd, err := os.Getwd()
|
pwd, err := os.Getwd()
|
||||||
r.NoError(err)
|
r.NoError(err)
|
||||||
|
|
||||||
ch := filepath.Join(pwd, "..", "..",
|
ch := filepath.Join(pwd,
|
||||||
"examples",
|
"..",
|
||||||
|
"..",
|
||||||
|
"internal",
|
||||||
|
"testdata",
|
||||||
"app")
|
"app")
|
||||||
|
|
||||||
info := here.Info{
|
info := here.Info{
|
||||||
Dir: ch,
|
Dir: ch,
|
||||||
ImportPath: "github.com/markbates/pkger/examples/app",
|
ImportPath: "github.com/markbates/pkger/internal/testdata/app",
|
||||||
}
|
}
|
||||||
here.Cache(info.ImportPath, func(s string) (here.Info, error) {
|
here.Cache(info.ImportPath, func(s string) (here.Info, error) {
|
||||||
return info, nil
|
return info, nil
|
||||||
|
@ -98,12 +101,12 @@ var inbed = []string{
|
||||||
"github.com/gobuffalo/buffalo:/render/template_test.go",
|
"github.com/gobuffalo/buffalo:/render/template_test.go",
|
||||||
"github.com/gobuffalo/buffalo:/render/xml.go",
|
"github.com/gobuffalo/buffalo:/render/xml.go",
|
||||||
"github.com/gobuffalo/buffalo:/render/xml_test.go",
|
"github.com/gobuffalo/buffalo:/render/xml_test.go",
|
||||||
"github.com/markbates/pkger/examples/app:/",
|
"github.com/markbates/pkger/internal/testdata/app:/",
|
||||||
"github.com/markbates/pkger/examples/app:/public",
|
"github.com/markbates/pkger/internal/testdata/app:/public",
|
||||||
"github.com/markbates/pkger/examples/app:/public/images",
|
"github.com/markbates/pkger/internal/testdata/app:/public/images",
|
||||||
"github.com/markbates/pkger/examples/app:/public/images/mark-small.png",
|
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark-small.png",
|
||||||
"github.com/markbates/pkger/examples/app:/public/images/mark.png",
|
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark.png",
|
||||||
"github.com/markbates/pkger/examples/app:/public/images/mark_250px.png",
|
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark_250px.png",
|
||||||
"github.com/markbates/pkger/examples/app:/public/images/mark_400px.png",
|
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark_400px.png",
|
||||||
"github.com/markbates/pkger/examples/app:/public/index.html",
|
"github.com/markbates/pkger/internal/testdata/app:/public/index.html",
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
package stdos
|
package stdos
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/markbates/pkger/here"
|
"github.com/markbates/pkger/here"
|
||||||
|
@ -34,49 +30,3 @@ func Test_File_Stat_No_Info(t *testing.T) {
|
||||||
r.Equal(oi.Name(), info.Name())
|
r.Equal(oi.Name(), info.Name())
|
||||||
// r.Equal("", f.Name())
|
// r.Equal("", f.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_File_HTTP_Dir(t *testing.T) {
|
|
||||||
r := require.New(t)
|
|
||||||
|
|
||||||
her, err := here.Current()
|
|
||||||
r.NoError(err)
|
|
||||||
pkg, err := New(her)
|
|
||||||
r.NoError(err)
|
|
||||||
|
|
||||||
fp := filepath.Join("..", "..", "examples", "app", "public")
|
|
||||||
|
|
||||||
gots := httptest.NewServer(http.FileServer(http.Dir(fp)))
|
|
||||||
defer gots.Close()
|
|
||||||
|
|
||||||
dir, err := pkg.Open("/examples/app/public")
|
|
||||||
r.NoError(err)
|
|
||||||
|
|
||||||
pkgts := httptest.NewServer(http.FileServer(dir))
|
|
||||||
defer pkgts.Close()
|
|
||||||
|
|
||||||
paths := []string{
|
|
||||||
"/",
|
|
||||||
"/index.html",
|
|
||||||
"/images",
|
|
||||||
"/images/images/mark.png",
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, path := range paths {
|
|
||||||
t.Run(path, func(st *testing.T) {
|
|
||||||
r := require.New(st)
|
|
||||||
|
|
||||||
gores, err := http.Get(gots.URL + path)
|
|
||||||
r.NoError(err)
|
|
||||||
|
|
||||||
pkgres, err := http.Get(pkgts.URL + path)
|
|
||||||
r.NoError(err)
|
|
||||||
|
|
||||||
gobody, err := ioutil.ReadAll(gores.Body)
|
|
||||||
r.NoError(err)
|
|
||||||
|
|
||||||
pkgbody, err := ioutil.ReadAll(pkgres.Body)
|
|
||||||
r.NoError(err)
|
|
||||||
r.Equal(string(gobody), string(pkgbody))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|