diff --git a/examples/app/.gitignore b/internal/testdata/app/.gitignore similarity index 100% rename from examples/app/.gitignore rename to internal/testdata/app/.gitignore diff --git a/examples/app/Dockerfile b/internal/testdata/app/Dockerfile similarity index 100% rename from examples/app/Dockerfile rename to internal/testdata/app/Dockerfile diff --git a/examples/app/Makefile b/internal/testdata/app/Makefile similarity index 100% rename from examples/app/Makefile rename to internal/testdata/app/Makefile diff --git a/examples/app/go.mod b/internal/testdata/app/go.mod similarity index 100% rename from examples/app/go.mod rename to internal/testdata/app/go.mod diff --git a/examples/app/go.sum b/internal/testdata/app/go.sum similarity index 100% rename from examples/app/go.sum rename to internal/testdata/app/go.sum diff --git a/examples/app/main.go b/internal/testdata/app/main.go similarity index 96% rename from examples/app/main.go rename to internal/testdata/app/main.go index 21b7355..f92cd99 100644 --- a/examples/app/main.go +++ b/internal/testdata/app/main.go @@ -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) } diff --git a/examples/app/public/images/mark-small.png b/internal/testdata/app/public/images/mark-small.png similarity index 100% rename from examples/app/public/images/mark-small.png rename to internal/testdata/app/public/images/mark-small.png diff --git a/examples/app/public/images/mark.png b/internal/testdata/app/public/images/mark.png similarity index 100% rename from examples/app/public/images/mark.png rename to internal/testdata/app/public/images/mark.png diff --git a/examples/app/public/images/mark_250px.png b/internal/testdata/app/public/images/mark_250px.png similarity index 100% rename from examples/app/public/images/mark_250px.png rename to internal/testdata/app/public/images/mark_250px.png diff --git a/examples/app/public/images/mark_400px.png b/internal/testdata/app/public/images/mark_400px.png similarity index 100% rename from examples/app/public/images/mark_400px.png rename to internal/testdata/app/public/images/mark_400px.png diff --git a/examples/app/public/index.html b/internal/testdata/app/public/index.html similarity index 100% rename from examples/app/public/index.html rename to internal/testdata/app/public/index.html diff --git a/examples/app/templates/a.txt b/internal/testdata/app/templates/a.txt similarity index 100% rename from examples/app/templates/a.txt rename to internal/testdata/app/templates/a.txt diff --git a/examples/app/templates/b/b.txt b/internal/testdata/app/templates/b/b.txt similarity index 100% rename from examples/app/templates/b/b.txt rename to internal/testdata/app/templates/b/b.txt diff --git a/parser/parser_test.go b/parser/parser_test.go index 7871c36..967bc95 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -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", } diff --git a/pkger_test.go b/pkger_test.go index fabcf3f..ffb2a76 100644 --- a/pkger_test.go +++ b/pkger_test.go @@ -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 } diff --git a/pkging/mem/embed_test.go b/pkging/mem/embed_test.go index 977bcd3..5c65e11 100644 --- a/pkging/mem/embed_test.go +++ b/pkging/mem/embed_test.go @@ -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", } diff --git a/pkging/stdos/file_test.go b/pkging/stdos/file_test.go index e9eb4a1..a33f29d 100644 --- a/pkging/stdos/file_test.go +++ b/pkging/stdos/file_test.go @@ -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)) - }) - } -}