1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

rm duplicated code in env_test.go

This commit is contained in:
Carlos Alexandro Becker 2017-05-01 10:23:28 -03:00
parent 1b9fbdcdbb
commit 6c51f42871
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940

View File

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