From de2b5f438599ed301e64c1022e30dd1ba031af7d Mon Sep 17 00:00:00 2001 From: Jorin Vogel Date: Mon, 5 Jun 2017 18:28:29 +0200 Subject: [PATCH] Improve test coverage for archive skip option. --- pipeline/brew/brew_test.go | 14 ++++++++++++++ pipeline/build/build_test.go | 29 +++++++++++++++++++++++++++++ pipeline/fpm/fpm_test.go | 12 ++++++++++++ 3 files changed, 55 insertions(+) diff --git a/pipeline/brew/brew_test.go b/pipeline/brew/brew_test.go index 2da710082..025255018 100644 --- a/pipeline/brew/brew_test.go +++ b/pipeline/brew/brew_test.go @@ -186,6 +186,20 @@ func TestRunPipeDraftRelease(t *testing.T) { assert.False(client.CreatedFile) } +func TestRunPipeSkipArchive(t *testing.T) { + assert := assert.New(t) + var ctx = &context.Context{ + Config: config.Project{ + Archive: config.Archive{ + Skip: true, + }, + }, + } + client := &DummyClient{} + assert.NoError(doRun(ctx, client)) + assert.False(client.CreatedFile) +} + type DummyClient struct { CreatedFile bool } diff --git a/pipeline/build/build_test.go b/pipeline/build/build_test.go index 3053e4a4b..8743663de 100644 --- a/pipeline/build/build_test.go +++ b/pipeline/build/build_test.go @@ -76,6 +76,35 @@ func TestRunFullPipe(t *testing.T) { assert.True(exists(post), post) } +func TestRunPipeSkipArchive(t *testing.T) { + assert := assert.New(t) + folder, err := ioutil.TempDir("", "goreleasertest") + assert.NoError(err) + var binary = filepath.Join(folder, "binary-testing") + var config = config.Project{ + Dist: folder, + Build: config.Build{ + Binary: "testing", + Goos: []string{ + runtime.GOOS, + }, + Goarch: []string{ + runtime.GOARCH, + }, + }, + Archive: config.Archive{ + Skip: true, + NameTemplate: "binary-{{.Binary}}", + }, + } + var ctx = &context.Context{ + Config: config, + Archives: map[string]string{}, + } + assert.NoError(Pipe{}.Run(ctx)) + assert.True(exists(binary)) +} + func TestRunPipeArmBuilds(t *testing.T) { assert := assert.New(t) folder, err := ioutil.TempDir("", "goreleasertest") diff --git a/pipeline/fpm/fpm_test.go b/pipeline/fpm/fpm_test.go index 49f0ca59e..60f1a5f8c 100644 --- a/pipeline/fpm/fpm_test.go +++ b/pipeline/fpm/fpm_test.go @@ -23,6 +23,18 @@ func TestRunPipeNoFormats(t *testing.T) { assert.NoError(Pipe{}.Run(ctx)) } +func TestRunPipeSkipArchive(t *testing.T) { + var assert = assert.New(t) + var ctx = &context.Context{ + Config: config.Project{ + Archive: config.Archive{ + Skip: true, + }, + }, + } + assert.NoError(Pipe{}.Run(ctx)) +} + func TestRunPipe(t *testing.T) { var assert = assert.New(t) folder, err := ioutil.TempDir("", "archivetest")