-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathepp_test.go
67 lines (51 loc) · 1.25 KB
/
epp_test.go
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"fmt"
"os"
"testing"
"github.com/flosch/pongo2"
)
func init() {
os.Setenv("SPLIT_TEST", "value=with=equal=sings")
os.Setenv("KUBERNETES_ADDRESS", "https://192.168.99.100")
os.Setenv("FALSY", "")
}
func TestEnvVariables(t *testing.T) {
tpl := []byte("{{ SPLIT_TEST }}: {{ KUBERNETES_ADDRESS }}")
expected := fmt.Sprintf("%s: %s", os.Getenv("SPLIT_TEST"), os.Getenv("KUBERNETES_ADDRESS"))
res, err := Parse(tpl)
if err != nil {
t.Errorf("unexpected error '%s'", err)
}
if string(res) != expected {
t.Errorf("bad expansion: expected '%s', got '%s'", expected, res)
}
}
func TestEnvIf(t *testing.T) {
tpl := []byte(`
{% if FALSY %}
I shouldn't appear
{% endif %}
I should!
`)
expected := `
I should!
`
res, err := Parse(tpl)
if err != nil {
t.Errorf("unexpected error '%s'", err)
}
if string(res) != expected {
t.Errorf("bad expansion: expected '%s', got '%s'", expected, res)
}
}
func TestFilterBase64Encode(t *testing.T) {
actualResult, err := filterBase64Encode(pongo2.AsValue("Hello"), pongo2.AsValue(""))
if err != nil {
t.Errorf("unexpected error '%s'", err)
}
expectedResult := "SGVsbG8="
if actualResult.String() != expectedResult {
t.Errorf("Expected %s but got %s", expectedResult, actualResult)
}
}