1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00

test: cover context with timeout

This commit is contained in:
Carlos Alexandro Becker 2017-12-29 23:01:17 -02:00
parent bfa79275bc
commit f422e7734d
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940

View File

@ -2,6 +2,7 @@ package context
import (
"testing"
"time"
"github.com/goreleaser/goreleaser/config"
"github.com/stretchr/testify/assert"
@ -12,3 +13,12 @@ func TestNew(t *testing.T) {
assert.NotEmpty(t, ctx.Env)
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`)
}