mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-11 13:38:41 +02:00
<!-- Hi, thanks for contributing! Please make sure you read our CONTRIBUTING guide. Also, add tests and the respective documentation changes as well. --> <!-- If applied, this commit will... --> ... <!-- Why is this change being made? --> ... <!-- # Provide links to any relevant tickets, URLs or other resources --> ... --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
package prebuild
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/goreleaser/goreleaser/v2/internal/testlib"
|
|
"github.com/goreleaser/goreleaser/v2/pkg/config"
|
|
"github.com/goreleaser/goreleaser/v2/pkg/context"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestRun(t *testing.T) {
|
|
t.Run("good", func(t *testing.T) {
|
|
ctx := context.New(config.Project{
|
|
Env: []string{"FOO=bar"},
|
|
Builds: []config.Build{{Main: "{{ .Env.FOO }}"}},
|
|
})
|
|
require.NoError(t, Pipe{}.Run(ctx))
|
|
require.Equal(t, "bar", ctx.Config.Builds[0].Main)
|
|
})
|
|
|
|
t.Run("empty", func(t *testing.T) {
|
|
ctx := context.New(config.Project{
|
|
Env: []string{"FOO="},
|
|
Builds: []config.Build{{Main: "{{ .Env.FOO }}"}},
|
|
})
|
|
require.NoError(t, Pipe{}.Run(ctx))
|
|
require.Equal(t, ".", ctx.Config.Builds[0].Main)
|
|
})
|
|
|
|
t.Run("bad", func(t *testing.T) {
|
|
ctx := context.New(config.Project{
|
|
Builds: []config.Build{{Main: "{{ .Env.FOO }}"}},
|
|
})
|
|
testlib.RequireTemplateError(t, Pipe{}.Run(ctx))
|
|
})
|
|
}
|
|
|
|
func TestString(t *testing.T) {
|
|
require.NotEmpty(t, Pipe{}.String())
|
|
}
|