mirror of https://github.com/markbates/pkger.git
test for external module
This commit is contained in:
parent
20292c885b
commit
9ef79c78e8
|
@ -32,10 +32,14 @@ func Test_Parser_Ref(t *testing.T) {
|
||||||
|
|
||||||
files, err := res.Files()
|
files, err := res.Files()
|
||||||
r.NoError(err)
|
r.NoError(err)
|
||||||
r.Len(files, 22)
|
r.Len(files, 23)
|
||||||
|
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
|
if f.Path.Pkg == ref.Module.Path {
|
||||||
r.True(strings.HasPrefix(f.Abs, ref.Dir), "%q %q", f.Abs, ref.Dir)
|
r.True(strings.HasPrefix(f.Abs, ref.Dir), "%q %q", f.Abs, ref.Dir)
|
||||||
|
} else {
|
||||||
|
r.False(strings.HasPrefix(f.Abs, ref.Dir), "%q %q", f.Abs, ref.Dir)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,13 +142,22 @@ func (f *file) findStatCalls() error {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pt, err := info.Parse(s)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if pt.Pkg != info.Module.Path {
|
||||||
|
info, err = here.Package(pt.Pkg)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pf := &File{
|
pf := &File{
|
||||||
Abs: f.filename,
|
Abs: f.filename,
|
||||||
Here: info,
|
Here: info,
|
||||||
Path: here.Path{
|
Path: pt,
|
||||||
Pkg: info.Module.Path,
|
|
||||||
Name: s,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
decl := StatDecl{
|
decl := StatDecl{
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
go.sum
|
|
@ -1,19 +0,0 @@
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
||||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func Serve() {
|
func Serve() {
|
||||||
|
pkger.Stat("github.com/gobuffalo/buffalo:/logo.svg")
|
||||||
dir := http.FileServer(pkger.Dir("/public"))
|
dir := http.FileServer(pkger.Dir("/public"))
|
||||||
http.ListenAndServe(":3000", dir)
|
http.ListenAndServe(":3000", dir)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,20 @@ func Test_Stuff(t *testing.T) {
|
||||||
decls, err := parser.Parse(ref.Info)
|
decls, err := parser.Parse(ref.Info)
|
||||||
r.NoError(err)
|
r.NoError(err)
|
||||||
|
|
||||||
r.Len(decls, 9)
|
r.Len(decls, 10)
|
||||||
|
|
||||||
files, err := decls.Files()
|
files, err := decls.Files()
|
||||||
r.NoError(err)
|
r.NoError(err)
|
||||||
|
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
|
if f.Path.Pkg == ref.Module.Path {
|
||||||
r.Equal("app", f.Path.Pkg)
|
r.Equal("app", f.Path.Pkg)
|
||||||
|
} else {
|
||||||
|
r.NotEqual("app", f.Path.Pkg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Len(files, 22)
|
r.Len(files, 23)
|
||||||
|
|
||||||
bb := &bytes.Buffer{}
|
bb := &bytes.Buffer{}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue