pkger/pkging/pkgtest/walk.go

37 lines
600 B
Go
Raw Normal View History

2019-11-01 23:08:10 +03:00
package pkgtest
2019-10-31 00:32:47 +03:00
import (
"os"
"testing"
"github.com/markbates/pkger/pkging"
"github.com/stretchr/testify/require"
)
func WalkTest(t *testing.T, ref *Ref, pkg pkging.Pkger) {
r := require.New(t)
2019-11-01 00:20:15 +03:00
exp, err := LoadFiles("/public", ref, pkg)
r.NoError(err)
defer os.RemoveAll(ref.Dir)
2019-10-31 00:32:47 +03:00
name := "public"
var act []os.FileInfo
err = pkg.Walk("/"+name, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
act = append(act, info)
return nil
})
r.NoError(err)
r.Len(act, len(exp))
for i, info := range exp {
2019-11-01 22:53:54 +03:00
CmpFileInfo(t, info, act[i])
2019-10-31 00:32:47 +03:00
}
}