forked from mirror/pkger
thats what i get
This commit is contained in:
parent
53e641aa95
commit
14453cbd80
6
apply.go
6
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
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
package pkger
|
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue