2017-04-14 17:15:51 +02:00
|
|
|
package context
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2017-12-30 03:01:17 +02:00
|
|
|
"time"
|
2017-04-14 17:15:51 +02:00
|
|
|
|
|
|
|
"github.com/goreleaser/goreleaser/config"
|
2017-12-19 00:49:13 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
2017-04-14 17:15:51 +02:00
|
|
|
)
|
|
|
|
|
2017-12-17 19: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-02 02:34:32 +02:00
|
|
|
}
|
2017-12-30 03: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`)
|
|
|
|
}
|