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)) }