mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-06 03:13:48 +02:00
cf4aba68d3
* feat: global env * docs: hooks templateable, global env * docs: hooks templateable, global env * feat: templas on before hooks * docs: revert unwanted change * fix: use os.environ too * chore: travis * fix: goreleaser.yml
33 lines
695 B
Go
33 lines
695 B
Go
package context
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/config"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestNew(t *testing.T) {
|
|
assert.NoError(t, os.Setenv("FOO", "NOT BAR"))
|
|
assert.NoError(t, os.Setenv("BAR", "1"))
|
|
var ctx = New(config.Project{
|
|
Env: []string{
|
|
"FOO=BAR",
|
|
},
|
|
})
|
|
assert.Equal(t, "BAR", ctx.Env["FOO"])
|
|
assert.Equal(t, "1", ctx.Env["BAR"])
|
|
assert.Equal(t, 4, ctx.Parallelism)
|
|
}
|
|
|
|
func TestNewWithTimeout(t *testing.T) {
|
|
ctx, cancel := NewWithTimeout(config.Project{}, time.Second)
|
|
assert.NotEmpty(t, ctx.Env)
|
|
assert.Equal(t, 4, ctx.Parallelism)
|
|
cancel()
|
|
<-ctx.Done()
|
|
assert.EqualError(t, ctx.Err(), `context canceled`)
|
|
}
|