2017-04-14 12:15:51 -03:00
|
|
|
package context
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2017-12-29 23:01:17 -02:00
|
|
|
"time"
|
2017-04-14 12:15:51 -03:00
|
|
|
|
|
|
|
"github.com/goreleaser/goreleaser/config"
|
2017-12-18 20:49:13 -02:00
|
|
|
"github.com/stretchr/testify/assert"
|
2017-04-14 12:15:51 -03:00
|
|
|
)
|
|
|
|
|
2017-12-17 15:18:46 -02:00
|
|
|
func TestNew(t *testing.T) {
|
|
|
|
var ctx = New(config.Project{})
|
|
|
|
assert.NotEmpty(t, ctx.Env)
|
|
|
|
assert.Equal(t, 4, ctx.Parallelism)
|
2017-07-01 21:34:32 -03:00
|
|
|
}
|
2017-12-29 23:01:17 -02:00
|
|
|
|
|
|
|
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`)
|
|
|
|
}
|