move the testing app

This commit is contained in:
Mark Bates 2019-10-17 15:08:02 -04:00
parent ce4d917989
commit 372454529c
17 changed files with 29 additions and 74 deletions

View File

@ -43,7 +43,7 @@ func main() {
// : - 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
// 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 {
log.Fatal(err)
}

View File

Before

Width:  |  Height:  |  Size: 634 KiB

After

Width:  |  Height:  |  Size: 634 KiB

View File

Before

Width:  |  Height:  |  Size: 48 MiB

After

Width:  |  Height:  |  Size: 48 MiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

@ -16,15 +16,17 @@ func Test_Parser_App(t *testing.T) {
pwd, err := os.Getwd()
r.NoError(err)
ch := filepath.Join(pwd, "..",
"examples",
ch := filepath.Join(pwd,
"..",
"internal",
"testdata",
"app")
os.RemoveAll(filepath.Join(ch, "pkged.go"))
info := here.Info{
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) {
return info, nil
@ -81,12 +83,12 @@ var inbed = []string{
"github.com/gobuffalo/buffalo:/render/template_test.go",
"github.com/gobuffalo/buffalo:/render/xml.go",
"github.com/gobuffalo/buffalo:/render/xml_test.go",
"github.com/markbates/pkger/examples/app:/",
"github.com/markbates/pkger/examples/app:/public",
"github.com/markbates/pkger/examples/app:/public/images",
"github.com/markbates/pkger/examples/app:/public/images/mark-small.png",
"github.com/markbates/pkger/examples/app:/public/images/mark.png",
"github.com/markbates/pkger/examples/app:/public/images/mark_250px.png",
"github.com/markbates/pkger/examples/app:/public/images/mark_400px.png",
"github.com/markbates/pkger/examples/app:/public/index.html",
"github.com/markbates/pkger/internal/testdata/app:/",
"github.com/markbates/pkger/internal/testdata/app:/public",
"github.com/markbates/pkger/internal/testdata/app:/public/images",
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark-small.png",
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark.png",
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark_250px.png",
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark_400px.png",
"github.com/markbates/pkger/internal/testdata/app:/public/index.html",
}

View File

@ -96,7 +96,7 @@ func Test_Walk(t *testing.T) {
r := require.New(t)
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 {
return err
}

View File

@ -19,13 +19,16 @@ func Test_Pkger_Embedding(t *testing.T) {
pwd, err := os.Getwd()
r.NoError(err)
ch := filepath.Join(pwd, "..", "..",
"examples",
ch := filepath.Join(pwd,
"..",
"..",
"internal",
"testdata",
"app")
info := here.Info{
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) {
return info, nil
@ -98,12 +101,12 @@ var inbed = []string{
"github.com/gobuffalo/buffalo:/render/template_test.go",
"github.com/gobuffalo/buffalo:/render/xml.go",
"github.com/gobuffalo/buffalo:/render/xml_test.go",
"github.com/markbates/pkger/examples/app:/",
"github.com/markbates/pkger/examples/app:/public",
"github.com/markbates/pkger/examples/app:/public/images",
"github.com/markbates/pkger/examples/app:/public/images/mark-small.png",
"github.com/markbates/pkger/examples/app:/public/images/mark.png",
"github.com/markbates/pkger/examples/app:/public/images/mark_250px.png",
"github.com/markbates/pkger/examples/app:/public/images/mark_400px.png",
"github.com/markbates/pkger/examples/app:/public/index.html",
"github.com/markbates/pkger/internal/testdata/app:/",
"github.com/markbates/pkger/internal/testdata/app:/public",
"github.com/markbates/pkger/internal/testdata/app:/public/images",
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark-small.png",
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark.png",
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark_250px.png",
"github.com/markbates/pkger/internal/testdata/app:/public/images/mark_400px.png",
"github.com/markbates/pkger/internal/testdata/app:/public/index.html",
}

View File

@ -1,10 +1,6 @@
package stdos
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"path/filepath"
"testing"
"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("", 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))
})
}
}