pkger/parser/parser_test.go

52 lines
1.2 KiB
Go
Raw Normal View History

2019-08-01 19:03:12 +03:00
package parser
import (
2019-09-23 16:53:30 +03:00
"os"
2019-08-30 00:05:44 +03:00
"path/filepath"
2019-08-02 00:35:42 +03:00
"sort"
2019-08-01 19:03:12 +03:00
"testing"
2019-09-20 18:16:57 +03:00
"github.com/markbates/pkger/here"
2019-08-01 19:03:12 +03:00
"github.com/stretchr/testify/require"
)
func Test_Parser(t *testing.T) {
r := require.New(t)
2019-09-23 16:53:30 +03:00
pwd, err := os.Getwd()
r.NoError(err)
ch := filepath.Join(pwd, "..",
2019-09-21 19:51:29 +03:00
"examples",
2019-10-09 20:21:54 +03:00
"complex")
2019-09-20 18:16:57 +03:00
info := here.Info{
Dir: ch,
2019-10-09 20:21:54 +03:00
ImportPath: "github.com/markbates/pkger/examples/complex",
2019-09-20 18:16:57 +03:00
}
2019-09-23 16:53:30 +03:00
2019-09-20 18:16:57 +03:00
res, err := Parse(info)
2019-08-02 00:35:42 +03:00
2019-08-01 19:03:12 +03:00
r.NoError(err)
2019-08-09 04:51:58 +03:00
exp := []string{
2019-10-09 20:21:54 +03:00
"github.com/markbates/pkger/examples/complex:/",
"github.com/markbates/pkger/examples/complex:/go.mod",
// "github.com/markbates/pkger/examples/app:/public",
// "github.com/markbates/pkger/examples/app:/public/images/mark-small.png",
// "github.com/markbates/pkger/examples/app:/public/images/mark.png",
// "github.com/markbates/pkger/examples/app:/public/images/mark_250px.png",
// "github.com/markbates/pkger/examples/app:/public/images/mark_400px.png",
// "github.com/markbates/pkger/examples/app:/public/index.html",
2019-08-09 04:51:58 +03:00
}
2019-08-02 00:35:42 +03:00
sort.Strings(exp)
2019-10-09 20:21:54 +03:00
act := make([]string, len(res))
for i := 0; i < len(res); i++ {
act[i] = res[i].String()
2019-08-02 00:35:42 +03:00
}
sort.Strings(act)
2019-09-23 16:53:30 +03:00
// fmt.Printf("%#v\n", act)
2019-08-02 00:35:42 +03:00
r.Equal(exp, act)
2019-08-01 19:03:12 +03:00
}