mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-19 20:57:53 +02:00
refactor: Simplify docker test
Remove unnecessary fields in `TestRunPipe` test cases
This commit is contained in:
parent
64ce2d5bd6
commit
5af006f415
@ -160,7 +160,6 @@ func TestRunPipe(t *testing.T) {
|
|||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{
|
||||||
"{{.Tag}}-{{.Env.FOO}}",
|
"{{.Tag}}-{{.Env.FOO}}",
|
||||||
"v{{.Major}}.{{.Minor}}",
|
|
||||||
},
|
},
|
||||||
BuildFlagTemplates: []string{
|
BuildFlagTemplates: []string{
|
||||||
"--label=org.label-schema.version={{.Version}}",
|
"--label=org.label-schema.version={{.Version}}",
|
||||||
@ -169,7 +168,6 @@ func TestRunPipe(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expect: []string{
|
expect: []string{
|
||||||
registry + "goreleaser/test_run_pipe:v1.0.0-123",
|
registry + "goreleaser/test_run_pipe:v1.0.0-123",
|
||||||
registry + "goreleaser/test_run_pipe:v1.0",
|
|
||||||
},
|
},
|
||||||
assertImageLabels: shouldFindImagesWithLabels(
|
assertImageLabels: shouldFindImagesWithLabels(
|
||||||
"goreleaser/test_run_pipe",
|
"goreleaser/test_run_pipe",
|
||||||
@ -181,30 +179,22 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: true,
|
publish: true,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: registry + "goreleaser/multiplefiles1",
|
Image: registry + "goreleaser/multiplefiles1",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Dockerfile: "testdata/Dockerfile",
|
Dockerfile: "testdata/Dockerfile",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"latest",
|
Files: []string{"testdata/extra_file.txt"},
|
||||||
},
|
|
||||||
Files: []string{
|
|
||||||
"testdata/extra_file.txt",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Image: registry + "goreleaser/multiplefiles2",
|
Image: registry + "goreleaser/multiplefiles2",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Dockerfile: "testdata/Dockerfile",
|
Dockerfile: "testdata/Dockerfile",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"latest",
|
Files: []string{"testdata/extra_file.txt"},
|
||||||
},
|
|
||||||
Files: []string{
|
|
||||||
"testdata/extra_file.txt",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expect: []string{
|
expect: []string{
|
||||||
@ -245,27 +235,16 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: true,
|
publish: true,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: registry + "goreleaser/test_run_pipe",
|
Image: registry + "goreleaser/test_run_pipe",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Dockerfile: "testdata/Dockerfile",
|
Dockerfile: "testdata/Dockerfile",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
SkipPush: true,
|
SkipPush: true,
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"{{.Tag}}-{{.Env.FOO}}",
|
|
||||||
"v{{.Major}}",
|
|
||||||
"v{{.Major}}.{{.Minor}}",
|
|
||||||
"latest",
|
|
||||||
},
|
|
||||||
Files: []string{
|
|
||||||
"testdata/extra_file.txt",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expect: []string{
|
expect: []string{
|
||||||
registry + "goreleaser/test_run_pipe:v1.0.0-123",
|
|
||||||
registry + "goreleaser/test_run_pipe:v1",
|
|
||||||
registry + "goreleaser/test_run_pipe:v1.0",
|
|
||||||
registry + "goreleaser/test_run_pipe:latest",
|
registry + "goreleaser/test_run_pipe:latest",
|
||||||
},
|
},
|
||||||
assertImageLabels: noLabels,
|
assertImageLabels: noLabels,
|
||||||
@ -275,17 +254,12 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: true,
|
publish: true,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: registry + "goreleaser/test_run_pipe",
|
Image: registry + "goreleaser/test_run_pipe",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Dockerfile: "testdata/Dockerfile",
|
Dockerfile: "testdata/Dockerfile",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"{{.Version}}"},
|
||||||
"{{.Version}}",
|
|
||||||
},
|
|
||||||
Files: []string{
|
|
||||||
"testdata/extra_file.txt",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expect: []string{
|
expect: []string{
|
||||||
@ -298,22 +272,15 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: false,
|
publish: false,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: registry + "goreleaser/test_run_pipe",
|
Image: registry + "goreleaser/test_run_pipe",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Dockerfile: "testdata/Dockerfile",
|
Dockerfile: "testdata/Dockerfile",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"{{.Tag}}-{{.Env.FOO}}",
|
|
||||||
"latest",
|
|
||||||
},
|
|
||||||
Files: []string{
|
|
||||||
"testdata/extra_file.txt",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expect: []string{
|
expect: []string{
|
||||||
registry + "goreleaser/test_run_pipe:v1.0.0-123",
|
|
||||||
registry + "goreleaser/test_run_pipe:latest",
|
registry + "goreleaser/test_run_pipe:latest",
|
||||||
},
|
},
|
||||||
assertImageLabels: noLabels,
|
assertImageLabels: noLabels,
|
||||||
@ -323,14 +290,12 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: false,
|
publish: false,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: registry + "goreleaser/test_build_args",
|
Image: registry + "goreleaser/test_build_args",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Dockerfile: "testdata/Dockerfile",
|
Dockerfile: "testdata/Dockerfile",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"latest",
|
|
||||||
},
|
|
||||||
BuildFlagTemplates: []string{
|
BuildFlagTemplates: []string{
|
||||||
"--label=foo=bar",
|
"--label=foo=bar",
|
||||||
},
|
},
|
||||||
@ -346,14 +311,12 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: false,
|
publish: false,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: registry + "goreleaser/test_build_args",
|
Image: registry + "goreleaser/test_build_args",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Dockerfile: "testdata/Dockerfile",
|
Dockerfile: "testdata/Dockerfile",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"latest",
|
|
||||||
},
|
|
||||||
BuildFlagTemplates: []string{
|
BuildFlagTemplates: []string{
|
||||||
"--bad-flag",
|
"--bad-flag",
|
||||||
},
|
},
|
||||||
@ -366,14 +329,12 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: true,
|
publish: true,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: registry + "goreleaser/bad_dockerfile",
|
Image: registry + "goreleaser/bad_dockerfile",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Dockerfile: "testdata/Dockerfile.bad",
|
Dockerfile: "testdata/Dockerfile.bad",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"{{.Version}}",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
assertImageLabels: noLabels,
|
assertImageLabels: noLabels,
|
||||||
@ -400,14 +361,12 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: true,
|
publish: true,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: registry + "goreleaser/test_run_pipe",
|
Image: registry + "goreleaser/test_run_pipe",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Dockerfile: "testdata/Dockerfile",
|
Dockerfile: "testdata/Dockerfile",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"latest",
|
|
||||||
},
|
|
||||||
BuildFlagTemplates: []string{
|
BuildFlagTemplates: []string{
|
||||||
"--label=tag={{.Tag}",
|
"--label=tag={{.Tag}",
|
||||||
},
|
},
|
||||||
@ -437,14 +396,12 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: true,
|
publish: true,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: registry + "goreleaser/test_run_pipe",
|
Image: registry + "goreleaser/test_run_pipe",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Dockerfile: "testdata/Dockerfile",
|
Dockerfile: "testdata/Dockerfile",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"latest",
|
|
||||||
},
|
|
||||||
BuildFlagTemplates: []string{
|
BuildFlagTemplates: []string{
|
||||||
"--label=nope={{.Env.NOPE}}",
|
"--label=nope={{.Env.NOPE}}",
|
||||||
},
|
},
|
||||||
@ -465,19 +422,12 @@ func TestRunPipe(t *testing.T) {
|
|||||||
SkipPush: true,
|
SkipPush: true,
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{
|
||||||
"{{.Tag}}-{{.Env.FOO}}",
|
"{{.Tag}}-{{.Env.FOO}}",
|
||||||
"v{{.Major}}",
|
|
||||||
"v{{.Major}}.{{.Minor}}",
|
|
||||||
"latest",
|
"latest",
|
||||||
},
|
},
|
||||||
Files: []string{
|
|
||||||
"testdata/extra_file.txt",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expect: []string{
|
expect: []string{
|
||||||
registry + "goreleaser/mybin:v1.0.0-123",
|
registry + "goreleaser/mybin:v1.0.0-123",
|
||||||
registry + "goreleaser/mybin:v1",
|
|
||||||
registry + "goreleaser/mybin:v1.0",
|
|
||||||
registry + "goreleaser/mybin:latest",
|
registry + "goreleaser/mybin:latest",
|
||||||
},
|
},
|
||||||
assertImageLabels: noLabels,
|
assertImageLabels: noLabels,
|
||||||
@ -487,20 +437,16 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: true,
|
publish: true,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: "docker.io/nope",
|
Image: "docker.io/nope",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
Dockerfile: "testdata/Dockerfile",
|
Dockerfile: "testdata/Dockerfile",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"{{.Tag}}",
|
|
||||||
"latest",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expect: []string{
|
expect: []string{
|
||||||
"docker.io/nope:latest",
|
"docker.io/nope:latest",
|
||||||
"docker.io/nope:v1.0.0",
|
|
||||||
},
|
},
|
||||||
assertImageLabels: noLabels,
|
assertImageLabels: noLabels,
|
||||||
assertError: shouldErr(`requested access to the resource is denied`),
|
assertError: shouldErr(`requested access to the resource is denied`),
|
||||||
@ -509,14 +455,12 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: true,
|
publish: true,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: "whatever",
|
Image: "whatever",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
Dockerfile: "testdata/Dockerfilezzz",
|
Dockerfile: "testdata/Dockerfilezzz",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"{{.Tag}}",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
assertImageLabels: noLabels,
|
assertImageLabels: noLabels,
|
||||||
@ -526,17 +470,15 @@ func TestRunPipe(t *testing.T) {
|
|||||||
publish: true,
|
publish: true,
|
||||||
dockers: []config.Docker{
|
dockers: []config.Docker{
|
||||||
{
|
{
|
||||||
Image: "whatever",
|
Image: "whatever",
|
||||||
Goos: "linux",
|
Goos: "linux",
|
||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
|
Dockerfile: "testdata/Dockerfile",
|
||||||
|
TagTemplates: []string{"latest"},
|
||||||
Files: []string{
|
Files: []string{
|
||||||
"testdata/nope.txt",
|
"testdata/nope.txt",
|
||||||
},
|
},
|
||||||
Dockerfile: "testdata/Dockerfile",
|
|
||||||
TagTemplates: []string{
|
|
||||||
"{{.Tag}}",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
assertImageLabels: noLabels,
|
assertImageLabels: noLabels,
|
||||||
@ -717,7 +659,6 @@ func TestDefault(t *testing.T) {
|
|||||||
assert.Equal(t, ctx.Config.Builds[0].Binary, docker.Binary)
|
assert.Equal(t, ctx.Config.Builds[0].Binary, docker.Binary)
|
||||||
assert.Equal(t, "Dockerfile", docker.Dockerfile)
|
assert.Equal(t, "Dockerfile", docker.Dockerfile)
|
||||||
assert.Equal(t, []string{":{{ .Version }}"}, docker.ImageTemplates)
|
assert.Equal(t, []string{":{{ .Version }}"}, docker.ImageTemplates)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaultNoDockers(t *testing.T) {
|
func TestDefaultNoDockers(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user