1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00
goreleaser/pkg/context/context_test.go
Carlos Alexandro Becker cf4aba68d3
feat: global env and template-able before hooks (#974)
* 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
2019-03-03 14:12:22 -03:00

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