2019-09-03 18:29:28 +03:00
|
|
|
package mem
|
2019-09-01 00:00:24 +03:00
|
|
|
|
|
|
|
import (
|
2019-10-15 23:40:45 +03:00
|
|
|
"os"
|
2019-09-01 05:45:22 +03:00
|
|
|
"testing"
|
2019-09-01 00:00:24 +03:00
|
|
|
|
|
|
|
"github.com/markbates/pkger/here"
|
2019-09-12 04:29:39 +03:00
|
|
|
"github.com/markbates/pkger/pkging"
|
2019-09-03 18:29:28 +03:00
|
|
|
"github.com/markbates/pkger/pkging/pkgtest"
|
2019-10-15 23:40:45 +03:00
|
|
|
"github.com/markbates/pkger/pkging/stdos"
|
2019-09-01 00:00:24 +03:00
|
|
|
)
|
|
|
|
|
2019-09-03 18:29:28 +03:00
|
|
|
func Test_Pkger(t *testing.T) {
|
2019-09-12 04:29:39 +03:00
|
|
|
suite, err := pkgtest.NewSuite("memos", func() (pkging.Pkger, error) {
|
|
|
|
info, err := here.Current()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-09-20 17:56:26 +03:00
|
|
|
pkg, err := New(info)
|
2019-09-12 04:29:39 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-10-15 23:40:45 +03:00
|
|
|
disk, err := stdos.New(info)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = disk.Walk("/examples/app/public", func(path string, info os.FileInfo, err error) error {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
pt, err := disk.Parse(path)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
f, err := disk.Open(pt.String())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
if err := pkg.Add(f); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
2019-09-20 17:56:26 +03:00
|
|
|
return pkg, nil
|
2019-09-12 04:29:39 +03:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2019-09-01 00:00:24 +03:00
|
|
|
|
2019-09-01 05:45:22 +03:00
|
|
|
suite.Test(t)
|
2019-09-01 00:00:24 +03:00
|
|
|
}
|