mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-08 03:31:59 +02:00
5ea003c6f6
* feat(docker): add buildpacks support Signed-off-by: Erkan Zileli <erkanzileli@gmail.com> * fix: move buildpacker imager code into own go file Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com> * fix: use docker imager push method for buildpack imager push Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com> * fix: return statement Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com> * move test into api_buildback_test Signed-off-by: Furkan <furkan.turkal@trendyol.com> * fix: use buildpacks instead of buildpack Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com> * fix(lint): fix lint issue * fix(buildpacks): use cwd instead of root directory * doc: add how to use a custom buildpack document Signed-off-by: Erkan Zileli <erkan.zileli@trendyol.com> * fix(doc): update docs as suggested Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Co-authored-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com> Co-authored-by: Furkan <furkan.turkal@trendyol.com> Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package docker
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestBuildCommandForBuildPack(t *testing.T) {
|
|
images := []string{"goreleaser/test_build_flag", "goreleaser/test_multiple_tags"}
|
|
tests := []struct {
|
|
name string
|
|
flags []string
|
|
expect []string
|
|
}{
|
|
{
|
|
name: "no flags without builder",
|
|
flags: []string{},
|
|
expect: []string{"build", images[0], "-t", images[1], "--builder=gcr.io/buildpacks/builder:v1"},
|
|
},
|
|
{
|
|
name: "single flag without builder",
|
|
flags: []string{"--clear-cache"},
|
|
expect: []string{"build", images[0], "-t", images[1], "--clear-cache", "--builder=gcr.io/buildpacks/builder:v1"},
|
|
},
|
|
{
|
|
name: "multiple flags without builder",
|
|
flags: []string{"--clear-cache", "--verbose"},
|
|
expect: []string{"build", images[0], "-t", images[1], "--clear-cache", "--verbose", "--builder=gcr.io/buildpacks/builder:v1"},
|
|
},
|
|
{
|
|
name: "builder with --builder flag",
|
|
flags: []string{"--builder=heroku/buildpacks:20"},
|
|
expect: []string{"build", images[0], "-t", images[1], "--builder=heroku/buildpacks:20"},
|
|
},
|
|
{
|
|
name: "builder with -B flag",
|
|
flags: []string{"-B=heroku/buildpacks:18"},
|
|
expect: []string{"build", images[0], "-t", images[1], "-B=heroku/buildpacks:18"},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
imager := buildPackImager{}
|
|
require.Equal(t, tt.expect, imager.buildCommand(images, tt.flags))
|
|
})
|
|
}
|
|
}
|