-
Notifications
You must be signed in to change notification settings - Fork 10
/
main_test.go
27 lines (19 loc) · 667 Bytes
/
main_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTemplatesJoin(t *testing.T) {
dataJson := []byte(`{"list": ["hallo", "welt", "bla"]}`)
dataTemplate := []byte(`{{ join ";" .list }}`)
test_config := readConfigBuffer(dataJson)
rendered := renderTemplateBuffer(test_config, dataTemplate)
assert.Equal(t, string(rendered), "hallo;welt;bla")
}
func TestTemplatesCalc(t *testing.T) {
dataJson := []byte(`{"num": 3}`)
dataTemplate := []byte(`{{ add .num 3 }}-{{ mul .num 3 }}`)
test_config := readConfigBuffer(dataJson)
rendered := renderTemplateBuffer(test_config, dataTemplate)
assert.Equal(t, string(rendered), "6-9")
}