1
1
mirror of https://github.com/goreleaser/nfpm synced 2024-10-01 02:21:49 +02:00

test: improved acceptance tests

This commit is contained in:
Carlos Alexandro Becker 2018-03-11 15:19:10 -03:00
parent 04ca909fdb
commit 02d4d8d5c8
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
9 changed files with 7 additions and 32 deletions

@ -1,7 +1,6 @@
package acceptance
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
@ -17,8 +16,8 @@ import (
_ "github.com/goreleaser/nfpm/rpm"
)
func accept(t *testing.T, name, format string) {
var config = fmt.Sprintf("./testdata/%s.yaml", name)
func accept(t *testing.T, name, conf, format, dockerfile string) {
var config = filepath.Join("./testdata", conf)
tmp, err := filepath.Abs("./testdata/tmp")
require.NoError(t, err)
var target = filepath.Join(tmp, name+"."+format)
@ -43,7 +42,7 @@ func accept(t *testing.T, name, format string) {
"docker",
"build",
"-f",
fmt.Sprintf("./testdata/%s.dockerfile", name),
filepath.Join("./testdata", dockerfile),
"./testdata",
)
t.Log("will exec:", cmd.Args)

@ -3,9 +3,9 @@ package acceptance
import "testing"
func TestSimpleDeb(t *testing.T) {
accept(t, "simple_deb", "deb")
accept(t, "simple_deb", "simple.yaml", "deb", "deb.dockerfile")
}
func TestComplexDeb(t *testing.T) {
accept(t, "complex_deb", "deb")
accept(t, "complex_deb", "complex.yaml", "deb", "deb.dockerfile")
}

@ -3,9 +3,9 @@ package acceptance
import "testing"
func TestSimpleRPM(t *testing.T) {
accept(t, "simple_rpm", "rpm")
accept(t, "simple_rpm", "simple.yaml", "rpm", "rpm.dockerfile")
}
func TestComplexRPM(t *testing.T) {
accept(t, "complex_rpm", "rpm")
accept(t, "complex_rpm", "complex.yaml", "rpm", "rpm.dockerfile")
}

@ -1,9 +0,0 @@
FROM ubuntu
COPY tmp/simple_deb.deb /tmp/foo.deb
RUN dpkg -i /tmp/foo.deb && \
test -e /usr/local/bin/fake && \
test -f /etc/foo/whatever.conf && \
echo wat >> /etc/foo/whatever.conf && \
dpkg -r foo && \
test -f /etc/foo/whatever.conf && \
test ! -f /usr/local/bin/fake

@ -1,15 +0,0 @@
name: "foo"
arch: "amd64"
platform: "linux"
version: "v1.2.3"
maintainer: "Foo Bar"
description: |
Foo bar
Multiple lines
vendor: "foobar"
homepage: "https://foobar.org"
license: "MIT"
files:
../testdata/fake: "/usr/local/bin/fake"
config_files:
../testdata/whatever.conf: "/etc/foo/whatever.conf"