From a25f6c37d55a64bc0d5abf3cb7e197178e8e4b40 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 14 Apr 2017 12:38:30 -0300 Subject: [PATCH 1/3] added more build pipe tests --- pipeline/build/build_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pipeline/build/build_test.go b/pipeline/build/build_test.go index 1f1af10eb..721c6f14a 100644 --- a/pipeline/build/build_test.go +++ b/pipeline/build/build_test.go @@ -73,6 +73,26 @@ func TestRunFullPipe(t *testing.T) { assert.True(exists(post), post) } +func TestRunPipeWithInvalidOS(t *testing.T) { + assert := assert.New(t) + var config = config.Project{ + Build: config.Build{ + Flags: "-v", + Goos: []string{ + "windows", + }, + Goarch: []string{ + "arm", + }, + }, + } + var ctx = &context.Context{ + Config: config, + Archives: map[string]string{}, + } + assert.NoError(Pipe{}.Run(ctx)) +} + func exists(file string) bool { _, err := os.Stat(file) return !os.IsNotExist(err) From 522048c62f6e2e57925cf02c8001f489f8107255 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 14 Apr 2017 12:45:38 -0300 Subject: [PATCH 2/3] more tests --- pipeline/build/build_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pipeline/build/build_test.go b/pipeline/build/build_test.go index 721c6f14a..1b67e339f 100644 --- a/pipeline/build/build_test.go +++ b/pipeline/build/build_test.go @@ -93,6 +93,33 @@ func TestRunPipeWithInvalidOS(t *testing.T) { assert.NoError(Pipe{}.Run(ctx)) } +func TestRunPipeFailingHooks(t *testing.T) { + assert := assert.New(t) + var config = config.Project{ + Build: config.Build{ + Hooks: config.Hooks{}, + Goos: []string{ + runtime.GOOS, + }, + Goarch: []string{ + runtime.GOARCH, + }, + }, + } + var ctx = &context.Context{ + Config: config, + Archives: map[string]string{}, + } + t.Run("pre-hook", func(t *testing.T) { + ctx.Config.Build.Hooks.Pre = "exit 1" + assert.Error(Pipe{}.Run(ctx)) + }) + t.Run("post-hook", func(t *testing.T) { + ctx.Config.Build.Hooks.Post = "exit 1" + assert.Error(Pipe{}.Run(ctx)) + }) +} + func exists(file string) bool { _, err := os.Stat(file) return !os.IsNotExist(err) From f5ab2de674d31a1a373281e8b1aaf94a9bf431c4 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 14 Apr 2017 12:50:20 -0300 Subject: [PATCH 3/3] testing failing builds --- pipeline/build/build_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pipeline/build/build_test.go b/pipeline/build/build_test.go index 1b67e339f..e48083ee4 100644 --- a/pipeline/build/build_test.go +++ b/pipeline/build/build_test.go @@ -73,6 +73,26 @@ func TestRunFullPipe(t *testing.T) { assert.True(exists(post), post) } +func TestBuildFailed(t *testing.T) { + assert := assert.New(t) + var config = config.Project{ + Build: config.Build{ + Flags: "-flag-that-dont-exists-to-force-failure", + Goos: []string{ + runtime.GOOS, + }, + Goarch: []string{ + runtime.GOARCH, + }, + }, + } + var ctx = &context.Context{ + Config: config, + Archives: map[string]string{}, + } + assert.Error(Pipe{}.Run(ctx)) +} + func TestRunPipeWithInvalidOS(t *testing.T) { assert := assert.New(t) var config = config.Project{