1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
goreleaser/pipeline/env/env_test.go
Carlos Alexandro Becker ce7a2227a0
fixed tests
2017-08-20 16:50:34 -03:00

69 lines
1.4 KiB
Go

package env
import (
"fmt"
"os"
"testing"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/stretchr/testify/assert"
)
func TestDescription(t *testing.T) {
assert.NotEmpty(t, Pipe{}.Description())
}
func TestValidEnv(t *testing.T) {
assert := assert.New(t)
assert.NoError(os.Setenv("GITHUB_TOKEN", "asdf"))
var ctx = &context.Context{
Config: config.Project{},
Validate: true,
Publish: true,
}
assert.NoError(Pipe{}.Run(ctx))
}
func TestInvalidEnv(t *testing.T) {
assert := assert.New(t)
assert.NoError(os.Unsetenv("GITHUB_TOKEN"))
var ctx = &context.Context{
Config: config.Project{},
Validate: true,
Publish: true,
}
assert.Error(Pipe{}.Run(ctx))
}
type flags struct {
Validate, Publish, Snapshot bool
}
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,
}
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
})
}
}