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",
|
||||||
@ -186,12 +184,8 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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",
|
||||||
@ -199,12 +193,8 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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{
|
||||||
@ -251,21 +241,10 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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,
|
||||||
@ -280,12 +259,7 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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{
|
||||||
@ -303,17 +277,10 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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,
|
||||||
@ -328,9 +295,7 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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",
|
||||||
},
|
},
|
||||||
@ -351,9 +316,7 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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",
|
||||||
},
|
},
|
||||||
@ -371,9 +334,7 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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,
|
||||||
@ -405,9 +366,7 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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}",
|
||||||
},
|
},
|
||||||
@ -442,9 +401,7 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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,
|
||||||
@ -492,15 +442,11 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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`),
|
||||||
@ -514,9 +460,7 @@ func TestRunPipe(t *testing.T) {
|
|||||||
Goarch: "amd64",
|
Goarch: "amd64",
|
||||||
Binary: "mybin",
|
Binary: "mybin",
|
||||||
Dockerfile: "testdata/Dockerfilezzz",
|
Dockerfile: "testdata/Dockerfilezzz",
|
||||||
TagTemplates: []string{
|
TagTemplates: []string{"latest"},
|
||||||
"{{.Tag}}",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
assertImageLabels: noLabels,
|
assertImageLabels: noLabels,
|
||||||
@ -530,13 +474,11 @@ func TestRunPipe(t *testing.T) {
|
|||||||
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