mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-03 13:11:48 +02:00
parent
5e4893234d
commit
3ae3a098e7
@ -151,7 +151,7 @@ func (t *Template) WithEnvS(envs []string) *Template {
|
||||
|
||||
// WithEnv overrides template's env field with the given environment map.
|
||||
func (t *Template) WithEnv(e map[string]string) *Template {
|
||||
t.fields[env] = e
|
||||
t.fields[env] = context.Env(e)
|
||||
return t
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ func TestEnv(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithEnv(t *testing.T) {
|
||||
func TestWithEnvS(t *testing.T) {
|
||||
ctx := testctx.New(
|
||||
testctx.WithEnv(map[string]string{"FOO": "BAR"}),
|
||||
testctx.WithCurrentTag("v1.2.3"),
|
||||
@ -198,6 +198,14 @@ func TestWithEnv(t *testing.T) {
|
||||
out, err = tpl.Apply(`{{ range $idx, $key := .Env }}{{ $idx }},{{ end }}`)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "BAR,FOO,NOVAL,", out)
|
||||
|
||||
out, err = tpl.Apply(`{{ envOrDefault "NOPE" "no" }}`)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "no", out)
|
||||
|
||||
out, err = tpl.Apply(`{{ isEnvSet "NOPE" }}`)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "false", out)
|
||||
}
|
||||
|
||||
func TestFuncMap(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user