From 9c9d1057ef134997bf017ea73bed6e89381b231e Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 30 Apr 2017 23:54:47 -0400 Subject: Reverting 9c4dfae and adding test to cover reason The refactoring in 9c4dfae was a bit too clever - I changed behaviour and started considering _empty_ envvars as valid. This _may_ be expected in some use-cases, but `getenv` didn't work that way before, and it's probably a surprising behaviour anyway. Signed-off-by: Dave Henderson --- test/integration/envvars.bats | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/integration/envvars.bats b/test/integration/envvars.bats index 6bec5695..c8a69ddd 100644 --- a/test/integration/envvars.bats +++ b/test/integration/envvars.bats @@ -27,6 +27,12 @@ load helper [[ "${output}" == "foo" ]] } +@test "default string with empty env var using getenv" { + FOO="" gomplate -i '{{getenv "FOO" "foo"}}' + [ "$status" -eq 0 ] + [[ "${output}" == "foo" ]] +} + @test "existant env var using .Env" { gomplate -i '{{.Env.HOME}}' [ "$status" -eq 0 ] -- cgit v1.2.3