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

68 lines
1.4 KiB
Go
Raw Normal View History

2017-03-25 20:40:45 -03:00
package env
import (
"os"
"testing"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"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"))
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(Pipe{}.Run(ctx))
}
func TestInvalidEnv(t *testing.T) {
assert := assert.New(t)
2017-04-09 10:43:23 -03:00
assert.NoError(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(Pipe{}.Run(ctx))
}
2017-04-29 12:49:22 +02:00
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))
}
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,
}
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))
}