thats what i get

This commit is contained in:
Mark Bates 2019-09-21 18:00:53 -04:00
parent 53e641aa95
commit 14453cbd80
3 changed files with 45 additions and 6 deletions

View File

@ -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
}

1
apply_test.go Normal file
View File

@ -0,0 +1 @@
package pkger

44
pkger_test.go Normal file
View File

@ -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)
}