From 6c51f4287157b097fba8f111e21e373084463c11 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 1 May 2017 10:23:28 -0300 Subject: [PATCH] rm duplicated code in env_test.go --- pipeline/env/env_test.go | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/pipeline/env/env_test.go b/pipeline/env/env_test.go index f58dc9397..fe8d6f732 100644 --- a/pipeline/env/env_test.go +++ b/pipeline/env/env_test.go @@ -1,6 +1,7 @@ package env import ( + "fmt" "os" "testing" @@ -35,33 +36,32 @@ func TestInvalidEnv(t *testing.T) { assert.Error(Pipe{}.Run(ctx)) } -func TestInvalidEnvDisabled(t *testing.T) { - assert := assert.New(t) - assert.NoError(os.Unsetenv("GITHUB_TOKEN")) - var ctx = &context.Context{ - Config: config.Project{}, - Validate: false, - Publish: true, - } - assert.NoError(Pipe{}.Run(ctx)) +type flags struct { + Validate, Publish, Snapshot bool } -func TestEnvWithoutPublish(t *testing.T) { - assert := assert.New(t) - assert.NoError(os.Unsetenv("GITHUB_TOKEN")) - var ctx = &context.Context{ - Config: config.Project{}, - Validate: true, - Publish: false, +func TestInvalidEnvChecksSkipped(t *testing.T) { + for _, flag := range []flags{ + { + Validate: false, + Publish: true, + }, { + Validate: true, + Publish: false, + }, { + Validate: true, + }, + } { + t.Run(fmt.Sprintf("%v", flag), func(t *testing.T) { + var assert = assert.New(t) + assert.NoError(os.Unsetenv("GITHUB_TOKEN")) + var ctx = &context.Context{ + Config: config.Project{}, + Validate: flag.Validate, + Publish: flag.Publish, + Snapshot: flag.Snapshot, + } + assert.NoError(Pipe{}.Run(ctx)) + }) } - assert.NoError(Pipe{}.Run(ctx)) -} - -func TestSkipValidate(t *testing.T) { - assert := assert.New(t) - var ctx = &context.Context{ - Config: config.Project{}, - Validate: false, - } - assert.NoError(Pipe{}.Run(ctx)) }