1
1
mirror of https://github.com/goreleaser/nfpm synced 2024-11-18 19:04:07 +01:00
nfpm/acceptance/acceptance_test.go

53 lines
1.2 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 (
"os"
"os/exec"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"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 configFile = filepath.Join("./testdata", conf)
2018-03-11 19:14:24 +01:00
tmp, err := filepath.Abs("./testdata/tmp")
require.NoError(t, err)
2018-03-11 19:24:44 +01:00
var packageName = name + "." + format
var target = filepath.Join(tmp, packageName)
2018-03-11 19:14:24 +01:00
require.NoError(t, os.MkdirAll(tmp, 0700))
config, err := nfpm.ParseFile(configFile)
2018-03-11 19:14:24 +01:00
require.NoError(t, err)
info, err := config.Get(format)
2018-03-11 19:14:24 +01:00
require.NoError(t, err)
2018-04-05 04:13:47 +02:00
require.NoError(t, nfpm.Validate(info))
2018-03-11 19:14:24 +01:00
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()
2018-03-11 19:14:24 +01:00
t.Log(string(bts))
cmd := exec.Command(
"docker", "build", "--rm", "--force-rm",
"-f", dockerfile,
"--build-arg", "package="+filepath.Join("tmp", packageName),
".",
2018-03-11 19:14:24 +01:00
)
cmd.Dir = "./testdata"
2018-03-11 19:14:24 +01:00
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
}