2019-10-31 18:06:20 +03:00
|
|
|
package stdos
|
2019-09-02 01:02:45 +03:00
|
|
|
|
|
|
|
import (
|
2019-09-12 04:29:39 +03:00
|
|
|
"io/ioutil"
|
2019-10-31 18:06:20 +03:00
|
|
|
"path/filepath"
|
2019-09-02 01:02:45 +03:00
|
|
|
"testing"
|
|
|
|
|
2019-10-31 18:06:20 +03:00
|
|
|
"github.com/markbates/pkger/here"
|
2019-09-12 04:29:39 +03:00
|
|
|
"github.com/markbates/pkger/pkging"
|
2019-10-31 18:06:20 +03:00
|
|
|
"github.com/markbates/pkger/pkging/costello"
|
2019-09-02 01:02:45 +03:00
|
|
|
)
|
|
|
|
|
2019-10-31 18:06:20 +03:00
|
|
|
func NewTemp(ref *costello.Ref) (pkging.Pkger, error) {
|
|
|
|
dir, err := ioutil.TempDir("", "stdos")
|
2019-09-12 04:29:39 +03:00
|
|
|
if err != nil {
|
2019-10-31 18:06:20 +03:00
|
|
|
return nil, err
|
2019-09-12 04:29:39 +03:00
|
|
|
}
|
2019-09-02 01:02:45 +03:00
|
|
|
|
2019-10-31 18:06:20 +03:00
|
|
|
info := here.Info{
|
|
|
|
Module: ref.Module,
|
|
|
|
ImportPath: ref.ImportPath,
|
|
|
|
Name: ref.Name,
|
|
|
|
Dir: dir,
|
|
|
|
}
|
|
|
|
info.Module.Dir = dir
|
|
|
|
info.Module.GoMod = filepath.Join(dir, "go.mod")
|
|
|
|
return New(info)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_Pkger(t *testing.T) {
|
|
|
|
costello.All(t, func(ref *costello.Ref) (pkging.Pkger, error) {
|
|
|
|
return NewTemp(ref)
|
|
|
|
})
|
2019-09-02 01:02:45 +03:00
|
|
|
}
|