1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00

test: default values for envs

refs #1795

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos A Becker 2021-05-31 01:53:40 +00:00
parent 64c73d7eba
commit ce7d3b0e89
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940

View File

@ -140,6 +140,9 @@ func TestWithEnv(t *testing.T) {
func TestFuncMap(t *testing.T) {
ctx := context.New(config.Project{
ProjectName: "proj",
Env: []string{
"FOO=bar",
},
})
wd, err := os.Getwd()
require.NoError(t, err)
@ -155,6 +158,16 @@ func TestFuncMap(t *testing.T) {
Name: "replace",
Expected: "1.24",
},
{
Template: `{{ if index .Env "SOME_ENV" }}{{ .Env.SOME_ENV }}{{ else }}default value{{ end }}`,
Name: "default value",
Expected: "default value",
},
{
Template: `{{ if index .Env "FOO" }}{{ .Env.FOO }}{{ else }}default value{{ end }}`,
Name: "default value set",
Expected: "bar",
},
{
Template: `{{ time "2006-01-02" }}`,
Name: "time YYYY-MM-DD",