1
1
mirror of https://github.com/goreleaser/nfpm synced 2024-11-18 23:14:12 +01:00
nfpm/acceptance/acceptance.go

53 lines
1.1 KiB
Go
Raw Normal View History

2018-03-11 18:58:53 +01:00
package acceptance
2018-03-11 19:14:24 +01:00
import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
yaml "gopkg.in/yaml.v1"
"github.com/goreleaser/nfpm"
// shut up
_ "github.com/goreleaser/nfpm/deb"
_ "github.com/goreleaser/nfpm/rpm"
)
2018-03-11 19:19:10 +01:00
func accept(t *testing.T, name, conf, format, dockerfile string) {
var config = filepath.Join("./testdata", conf)
2018-03-11 19:14:24 +01:00
tmp, err := filepath.Abs("./testdata/tmp")
require.NoError(t, err)
var target = filepath.Join(tmp, name+"."+format)
require.NoError(t, os.MkdirAll(tmp, 0700))
bts, err := ioutil.ReadFile(config)
require.NoError(t, err)
var info nfpm.Info
err = yaml.Unmarshal(bts, &info)
require.NoError(t, err)
pkg, err := nfpm.Get(format)
require.NoError(t, err)
f, err := os.Create(target)
require.NoError(t, err)
require.NoError(t, pkg.Package(nfpm.WithDefaults(info), f))
bts, _ = exec.Command("pwd").CombinedOutput()
t.Log(string(bts))
cmd := exec.Command(
"docker",
"build",
"-f",
2018-03-11 19:19:10 +01:00
filepath.Join("./testdata", dockerfile),
2018-03-11 19:14:24 +01:00
"./testdata",
)
t.Log("will exec:", cmd.Args)
bts, err = cmd.CombinedOutput()
t.Log("output:", string(bts))
require.NoError(t, err)
2018-03-11 18:58:53 +01:00
}