github.com/axxelG/goreleaser@v0.92.0/pkg/context/context_test.go (about)

     1  package context
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/goreleaser/goreleaser/pkg/config"
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  func TestNew(t *testing.T) {
    12  	var ctx = New(config.Project{})
    13  	assert.NotEmpty(t, ctx.Env)
    14  	assert.Equal(t, 4, ctx.Parallelism)
    15  }
    16  
    17  func TestNewWithTimeout(t *testing.T) {
    18  	ctx, cancel := NewWithTimeout(config.Project{}, time.Second)
    19  	assert.NotEmpty(t, ctx.Env)
    20  	assert.Equal(t, 4, ctx.Parallelism)
    21  	cancel()
    22  	<-ctx.Done()
    23  	assert.EqualError(t, ctx.Err(), `context canceled`)
    24  }