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

66 lines
1.3 KiB
Go
Raw Normal View History

2017-03-25 20:40:45 -03:00
package env
import (
2017-05-01 10:23:28 -03:00
"fmt"
2017-03-25 20:40:45 -03:00
"os"
"testing"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
2017-08-20 16:50:34 -03:00
"github.com/goreleaser/goreleaser/internal/testlib"
2017-03-25 20:40:45 -03:00
"github.com/stretchr/testify/assert"
)
func TestDescription(t *testing.T) {
assert.NotEmpty(t, Pipe{}.Description())
}
func TestValidEnv(t *testing.T) {
assert.NoError(t, os.Setenv("GITHUB_TOKEN", "asdf"))
2017-03-25 20:40:45 -03:00
var ctx = &context.Context{
Config: config.Project{},
Validate: true,
2017-04-29 12:49:22 +02:00
Publish: true,
2017-03-25 20:40:45 -03:00
}
assert.NoError(t, Pipe{}.Run(ctx))
2017-03-25 20:40:45 -03:00
}
func TestInvalidEnv(t *testing.T) {
assert.NoError(t, os.Unsetenv("GITHUB_TOKEN"))
2017-03-25 20:40:45 -03:00
var ctx = &context.Context{
Config: config.Project{},
Validate: true,
2017-04-29 12:49:22 +02:00
Publish: true,
2017-03-25 20:40:45 -03:00
}
assert.Error(t, Pipe{}.Run(ctx))
2017-03-25 20:40:45 -03:00
}
2017-05-01 10:23:28 -03:00
type flags struct {
Validate, Publish, Snapshot bool
2017-04-29 12:49:22 +02:00
}
2017-05-01 10:23:28 -03:00
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) {
assert.NoError(t, os.Unsetenv("GITHUB_TOKEN"))
2017-05-01 10:23:28 -03:00
var ctx = &context.Context{
Config: config.Project{},
Validate: flag.Validate,
Publish: flag.Publish,
Snapshot: flag.Snapshot,
}
2017-08-20 16:50:34 -03:00
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
2017-05-01 10:23:28 -03:00
})
}
}