summaryrefslogtreecommitdiff
path: root/internal/tests/integration/missing_key_test.go
blob: 076ff236b98a862044df45f3fb4ab972849a4533 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package integration

import (
	"testing"
)

func TestMissingKey_Default(t *testing.T) {
	inOutTest(t, `{{ .name }}`, "<no value>", "--missing-key", "default")
}

func TestMissingKey_Zero(t *testing.T) {
	inOutTest(t, `{{ .name }}`, "<no value>", "--missing-key", "zero")
}

func TestMissingKey_Fallback(t *testing.T) {
	inOutTest(t, `{{ .name | default "Alex" }}`, "Alex", "--missing-key", "default")
}

func TestMissingKey_NotSpecified(t *testing.T) {
	inOutContainsError(t, `{{ .name | default "Alex" }}`, `map has no entry for key \"name\"`)
}

func TestMissingKey_Error(t *testing.T) {
	inOutContainsError(t, `{{ .name | default "Alex" }}`, `map has no entry for key \"name\"`, "--missing-key", "error")
}