mirror of
https://github.com/goreleaser/goreleaser.git
synced 2026-06-19 23:24:39 +02:00
added some docker pipe tests
This commit is contained in:
@@ -7,10 +7,12 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/pipeline"
|
||||
|
||||
"github.com/apex/log"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,15 +1,73 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/pipeline"
|
||||
"github.com/tj/assert"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRunPipe(t *testing.T) {
|
||||
var assert = assert.New(t)
|
||||
folder, err := ioutil.TempDir("", "archivetest")
|
||||
assert.NoError(err)
|
||||
var dist = filepath.Join(folder, "dist")
|
||||
assert.NoError(os.Mkdir(dist, 0755))
|
||||
assert.NoError(os.Mkdir(filepath.Join(dist, "mybin"), 0755))
|
||||
var binPath = filepath.Join(dist, "mybin", "mybin")
|
||||
_, err = os.Create(binPath)
|
||||
assert.NoError(err)
|
||||
// this might fail as the image doesnt exist yet, so lets ignore the error
|
||||
_ = exec.Command("docker", "rmi", "goreleaser/test_run_pipe:v1.0.0").Run()
|
||||
var ctx = &context.Context{
|
||||
Git: context.GitInfo{
|
||||
CurrentTag: "v1.0.0",
|
||||
},
|
||||
Publish: true,
|
||||
Config: config.Project{
|
||||
ProjectName: "mybin",
|
||||
Dist: dist,
|
||||
Dockers: []config.Docker{
|
||||
{
|
||||
Image: "goreleaser/test_run_pipe",
|
||||
Goos: "linux",
|
||||
Goarch: "amd64",
|
||||
Dockerfile: "testdata/Dockerfile",
|
||||
Binary: "mybin",
|
||||
},
|
||||
{
|
||||
Image: "goreleaser/test_run_pipe_nope",
|
||||
Goos: "linux",
|
||||
Goarch: "amd64",
|
||||
Dockerfile: "testdata/Dockerfile",
|
||||
Binary: "otherbin",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, plat := range []string{"linuxamd64", "linux386", "darwinamd64"} {
|
||||
ctx.AddBinary(plat, "mybin", "mybin", binPath)
|
||||
}
|
||||
assert.NoError(Pipe{}.Run(ctx))
|
||||
// this might should not fail as the image should have been created when
|
||||
// the step ran
|
||||
assert.NoError(
|
||||
exec.Command("docker", "rmi", "goreleaser/test_run_pipe:v1.0.0").Run(),
|
||||
)
|
||||
// the test_run_pipe_nope image should not have been created, so deleting
|
||||
// it should fail
|
||||
assert.Error(
|
||||
exec.Command("docker", "rmi", "goreleaser/test_run_pipe_nope:v1.0.0").Run(),
|
||||
)
|
||||
}
|
||||
|
||||
func TestDescription(t *testing.T) {
|
||||
var assert = assert.New(t)
|
||||
assert.NotEmpty(Pipe{}.Description())
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
FROM scratch
|
||||
ADD mybin /
|
||||
Reference in New Issue
Block a user