1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/pipe/prebuild/prebuild_test.go
Carlos Alexandro Becker a6a6e11cc9
fix: template main with gomod.proxy (#2834)
* refactor: rename file

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* fix: template main with gomod.proxy

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
2022-01-14 10:33:11 -03:00

41 lines
1.0 KiB
Go

package prebuild
import (
"testing"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/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 }}"}},
})
require.EqualError(t, Pipe{}.Run(ctx), `template: tmpl:1:7: executing "tmpl" at <.Env.FOO>: map has no entry for key "FOO"`)
})
}
func TestString(t *testing.T) {
require.NotEmpty(t, Pipe{}.String())
}