mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-31 21:55:34 +02:00
* refactor: use require on all tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * refactor: use require on all tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
33 lines
704 B
Go
33 lines
704 B
Go
package context
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/config"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNew(t *testing.T) {
|
|
require.NoError(t, os.Setenv("FOO", "NOT BAR"))
|
|
require.NoError(t, os.Setenv("BAR", "1"))
|
|
var ctx = New(config.Project{
|
|
Env: []string{
|
|
"FOO=BAR",
|
|
},
|
|
})
|
|
require.Equal(t, "BAR", ctx.Env["FOO"])
|
|
require.Equal(t, "1", ctx.Env["BAR"])
|
|
require.Equal(t, 4, ctx.Parallelism)
|
|
}
|
|
|
|
func TestNewWithTimeout(t *testing.T) {
|
|
ctx, cancel := NewWithTimeout(config.Project{}, time.Second)
|
|
require.NotEmpty(t, ctx.Env)
|
|
require.Equal(t, 4, ctx.Parallelism)
|
|
cancel()
|
|
<-ctx.Done()
|
|
require.EqualError(t, ctx.Err(), `context canceled`)
|
|
}
|