forked from mirror/pkger
comedy cards
This commit is contained in:
parent
68e3d84918
commit
a2cc422288
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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)))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package pkgtest
|
||||
|
||||
import "strings"
|
||||
|
||||
func clean(s string) string {
|
||||
s = strings.TrimSpace(s)
|
||||
s = strings.ReplaceAll(s, "\\", "/")
|
||||
return s
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue