From d8987e281fe9ef62e6a260784c30d9f7d4dfab38 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 17 Dec 2017 20:25:54 -0200 Subject: [PATCH] test: fixing build pipe tets --- pipeline/build/build_test.go | 48 ++++-------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) diff --git a/pipeline/build/build_test.go b/pipeline/build/build_test.go index c4c01934a..753d4c7a9 100644 --- a/pipeline/build/build_test.go +++ b/pipeline/build/build_test.go @@ -46,7 +46,7 @@ func TestRunFullPipe(t *testing.T) { folder, back := testlib.Mktmp(t) defer back() writeGoodMain(t, folder) - var binary = filepath.Join(folder, "testing") + var binary = filepath.Join(folder, buildtarget.Runtime.String(), "testing") var pre = filepath.Join(folder, "pre") var post = filepath.Join(folder, "post") var config = config.Project{ @@ -80,11 +80,12 @@ func TestRunFullPipe(t *testing.T) { assert.True(t, exists(post), post) } +// TODO: this test is not irrelevant and could probably be removed func TestRunPipeFormatBinary(t *testing.T) { folder, back := testlib.Mktmp(t) defer back() writeGoodMain(t, folder) - var binary = filepath.Join(folder, "binary-testing-bar") + var binary = filepath.Join(folder, buildtarget.Runtime.String(), "testing") var config = config.Project{ ProjectName: "testing", Dist: folder, @@ -99,22 +100,17 @@ func TestRunPipeFormatBinary(t *testing.T) { }, }, }, - Archive: config.Archive{ - Format: "binary", - NameTemplate: "binary-{{.Binary}}-{{.Env.Foo}}", - }, } ctx := context.New(config) - ctx.Env = map[string]string{"Foo": "bar"} assert.NoError(t, Pipe{}.Run(ctx)) - assert.True(t, exists(binary)) + assert.True(t, exists(binary), "file %s does not exist", binary) } func TestRunPipeArmBuilds(t *testing.T) { folder, back := testlib.Mktmp(t) defer back() writeGoodMain(t, folder) - var binary = filepath.Join(folder, "armtesting") + var binary = filepath.Join(folder, "linuxarm6", "armtesting") var config = config.Project{ Builds: []config.Build{ { @@ -178,40 +174,6 @@ func TestRunPipeWithInvalidOS(t *testing.T) { assert.NoError(t, Pipe{}.Run(context.New(config))) } -func TestRunInvalidNametemplate(t *testing.T) { - folder, back := testlib.Mktmp(t) - defer back() - writeGoodMain(t, folder) - for format, msg := range map[string]string{ - "binary": `template: bar:1: unexpected "}" in operand`, - "tar.gz": `template: foo:1: unexpected "}" in operand`, - "zip": `template: foo:1: unexpected "}" in operand`, - } { - t.Run(format, func(t *testing.T) { - var config = config.Project{ - ProjectName: "foo", - Builds: []config.Build{ - { - Binary: "bar", - Flags: "-v", - Goos: []string{ - runtime.GOOS, - }, - Goarch: []string{ - runtime.GOARCH, - }, - }, - }, - Archive: config.Archive{ - Format: format, - NameTemplate: "{{.Binary}", - }, - } - assert.EqualError(t, Pipe{}.Run(context.New(config)), msg) - }) - } -} - func TestRunInvalidLdflags(t *testing.T) { folder, back := testlib.Mktmp(t) defer back()