comedy cards

This commit is contained in:
Mark Bates 2019-10-16 09:50:40 -04:00
parent 68e3d84918
commit a2cc422288
4 changed files with 19 additions and 7 deletions

View File

@ -1,7 +1,6 @@
package pkger
import (
"fmt"
"os"
"path/filepath"
"testing"
@ -106,7 +105,6 @@ func Test_Walk(t *testing.T) {
})
r.NoError(err)
fmt.Println(">>>TODO pkger_test.go:109: files ", files)
r.True(len(files) > 10)
}

View File

@ -97,8 +97,10 @@ func (s Suite) Test_HTTP_Dir(t *testing.T) {
b, err := ioutil.ReadAll(res.Body)
r.NoError(err)
r.Contains(string(b), tt.exp)
r.NotContains(string(b), "mark.png")
s := clean(string(b))
r.Contains(s, tt.exp)
r.NotContains(s, "mark.png")
})
}
}
@ -152,7 +154,7 @@ func (s Suite) Test_HTTP_Dir_IndexHTML(t *testing.T) {
b, err := ioutil.ReadAll(res.Body)
r.NoError(err)
body := string(b)
body := clean(string(b))
r.Contains(body, exp)
r.NotContains(body, "mark.png")
})
@ -226,7 +228,8 @@ func (s Suite) Test_HTTP_File(t *testing.T) {
r.NoError(err)
exp := strings.ReplaceAll(string(gobody), tdir, "")
r.Equal(exp, string(pkgbody))
exp = clean(exp)
r.Equal(exp, clean(string(pkgbody)))
})
}
})

View File

@ -0,0 +1,9 @@
package pkgtest
import "strings"
func clean(s string) string {
s = strings.TrimSpace(s)
s = strings.ReplaceAll(s, "\\", "/")
return s
}

View File

@ -181,7 +181,9 @@ func (f *Pkger) Walk(p string, wf filepath.WalkFunc) error {
if err != nil {
return err
}
path = strings.TrimPrefix(path, filepath.Dir(f.Here.ImportPath))
fmt.Println("path", path)
path = strings.TrimPrefix(path, f.Here.Dir)
fmt.Println("path", path)
pt, err := f.Parse(fmt.Sprintf("%s:%s", pt.Pkg, path))
if err != nil {
return err