From 14453cbd80232c5cef25c23a0a08777db1b10f15 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Sat, 21 Sep 2019 18:00:53 -0400 Subject: [PATCH] thats what i get --- apply.go | 6 ------ apply_test.go | 1 + pkger_test.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 apply_test.go create mode 100644 pkger_test.go diff --git a/apply.go b/apply.go index c7e9160..de3fe6f 100644 --- a/apply.go +++ b/apply.go @@ -1,24 +1,18 @@ package pkger import ( - "log" "os" - "sync" "github.com/markbates/pkger/pkging" "github.com/markbates/pkger/pkging/pkgutil" ) var current pkging.Pkger -var gil = &sync.RWMutex{} func Apply(pkg pkging.Pkger, err error) error { if err := pkgutil.Dump(os.Stdout, pkg); err != nil { - log.Fatal(err) return err } - gil.Lock() - defer gil.Unlock() current = pkging.Wrap(current, pkg) return nil } diff --git a/apply_test.go b/apply_test.go new file mode 100644 index 0000000..df6d462 --- /dev/null +++ b/apply_test.go @@ -0,0 +1 @@ +package pkger diff --git a/pkger_test.go b/pkger_test.go new file mode 100644 index 0000000..53a717d --- /dev/null +++ b/pkger_test.go @@ -0,0 +1,44 @@ +package pkger + +import ( + "os" + "path/filepath" + "testing" + + "github.com/markbates/pkger/pkging" + "github.com/stretchr/testify/require" +) + +func Test_Parse(t *testing.T) { + r := require.New(t) + + pt, err := Parse("github.com/rocket/ship:/little") + r.NoError(err) + r.Equal("github.com/rocket/ship", pt.Pkg) + r.Equal("/little", pt.Name) +} + +func Test_Abs(t *testing.T) { + r := require.New(t) + + s, err := Abs(":/rocket.ship") + r.NoError(err) + + pwd, err := os.Getwd() + r.NoError(err) + r.Equal(filepath.Join(pwd, "rocket.ship"), s) +} + +func Test_AbsPath(t *testing.T) { + r := require.New(t) + + s, err := AbsPath(pkging.Path{ + Pkg: "github.com/markbates/pkger", + Name: "/rocket.ship", + }) + r.NoError(err) + + pwd, err := os.Getwd() + r.NoError(err) + r.Equal(filepath.Join(pwd, "rocket.ship"), s) +}