1
1
Fork 0
mirror of https://github.com/goreleaser/nfpm synced 2024-05-27 00:36:10 +02:00

test: fix duplicated code and other issues

This commit is contained in:
Carlos Alexandro Becker 2018-06-04 09:08:27 -03:00
parent 7d40a1a171
commit a0f04ab682
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
5 changed files with 50 additions and 81 deletions

View File

@ -1,6 +1,7 @@
package acceptance
import (
"fmt"
"os"
"os/exec"
"path/filepath"
@ -14,6 +15,52 @@ import (
_ "github.com/goreleaser/nfpm/rpm"
)
var formats = []string{"deb", "rpm"}
func TestSimple(t *testing.T) {
for _, format := range formats {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, fmt.Sprintf("simple_%s", format), "simple.yaml", format, fmt.Sprintf("%s.dockerfile", format))
})
t.Run("i386", func(t *testing.T) {
t.Parallel()
accept(t, fmt.Sprintf("simple_%s_386", format), "simple.386.yaml", format, fmt.Sprintf("%s.386.dockerfile", format))
})
}
}
func TestComplex(t *testing.T) {
for _, format := range formats {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, fmt.Sprintf("complex_%s", format), "complex.yaml", format, fmt.Sprintf("%s.complex.dockerfile", format))
})
t.Run("i386", func(t *testing.T) {
t.Parallel()
accept(t, fmt.Sprintf("complex_%s_386", format), "complex.386.yaml", format, fmt.Sprintf("%s.386.complex.dockerfile", format))
})
}
}
func TestComplexOverridesDeb(t *testing.T) {
for _, format := range formats {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, fmt.Sprintf("overrides_%s", format), "overrides.yaml", format, fmt.Sprintf("%s.overrides.dockerfile", format))
})
}
}
func TestMinDeb(t *testing.T) {
for _, format := range formats {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, fmt.Sprintf("min_%s", format), "min.yaml", format, fmt.Sprintf("%s.min.dockerfile", format))
})
}
}
func accept(t *testing.T, name, conf, format, dockerfile string) {
var configFile = filepath.Join("./testdata", conf)
tmp, err := filepath.Abs("./testdata/tmp")

View File

@ -1,39 +0,0 @@
package acceptance
import "testing"
func TestSimpleDeb(t *testing.T) {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, "simple_deb", "simple.yaml", "deb", "deb.dockerfile")
})
t.Run("i386", func(t *testing.T) {
t.Parallel()
accept(t, "simple_deb_386", "simple.386.yaml", "deb", "deb.386.dockerfile")
})
}
func TestComplexDeb(t *testing.T) {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, "complex_deb", "complex.yaml", "deb", "deb.complex.dockerfile")
})
t.Run("i386", func(t *testing.T) {
t.Parallel()
accept(t, "complex_deb_386", "complex.386.yaml", "deb", "deb.386.complex.dockerfile")
})
}
func TestComplexOverridesDeb(t *testing.T) {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, "overrides_deb", "overrides.yaml", "deb", "deb.overrides.dockerfile")
})
}
func TestMinDeb(t *testing.T) {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, "min_deb", "min.yaml", "deb", "deb.min.dockerfile")
})
}

View File

@ -1,39 +0,0 @@
package acceptance
import "testing"
func TestSimpleRPM(t *testing.T) {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, "simple_rpm", "simple.yaml", "rpm", "rpm.dockerfile")
})
t.Run("i386", func(t *testing.T) {
t.Parallel()
accept(t, "simple_rpm_386", "simple.386.yaml", "rpm", "rpm.386.dockerfile")
})
}
func TestComplexRPM(t *testing.T) {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, "complex_rpm", "complex.yaml", "rpm", "rpm.complex.dockerfile")
})
t.Run("i386", func(t *testing.T) {
t.Parallel()
accept(t, "complex_rpm_386", "complex.386.yaml", "rpm", "rpm.386.complex.dockerfile")
})
}
func TestComplexOverridesRPM(t *testing.T) {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, "overrides_rpm", "overrides.yaml", "rpm", "rpm.overrides.dockerfile")
})
}
func TestMinRPM(t *testing.T) {
t.Run("amd64", func(t *testing.T) {
t.Parallel()
accept(t, "min_rpm", "min.yaml", "rpm", "rpm.min.dockerfile")
})
}

View File

@ -86,7 +86,7 @@ func TestControl(t *testing.T) {
}))
var golden = "testdata/control.golden"
if *update {
ioutil.WriteFile(golden, w.Bytes(), 0655)
ioutil.WriteFile(golden, w.Bytes(), 0655) //nolint:errcheck
}
bts, err := ioutil.ReadFile(golden)
assert.NoError(t, err)
@ -141,7 +141,7 @@ func TestNoJoinsControl(t *testing.T) {
}))
var golden = "testdata/control2.golden"
if *update {
ioutil.WriteFile(golden, w.Bytes(), 0655)
ioutil.WriteFile(golden, w.Bytes(), 0655) //nolint:errcheck
}
bts, err := ioutil.ReadFile(golden)
assert.NoError(t, err)

View File

@ -75,7 +75,7 @@ func TestSpec(t *testing.T) {
var w bytes.Buffer
assert.NoError(tt, writeSpec(&w, exampleInfo(), vs))
if *update {
ioutil.WriteFile(golden, w.Bytes(), 0655)
ioutil.WriteFile(golden, w.Bytes(), 0655) //nolint:errcheck
}
bts, err := ioutil.ReadFile(golden)
assert.NoError(tt, err)