From f670bfcb13320623e938fdb283201c0a887da7f3 Mon Sep 17 00:00:00 2001 From: Oliver Steele Date: Fri, 21 Jul 2017 11:35:11 -0400 Subject: [PATCH] Add top-level test cases for &map, struct The are from #23 --- engine_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/engine_test.go b/engine_test.go index 1ecc4c3..8be18c6 100644 --- a/engine_test.go +++ b/engine_test.go @@ -35,3 +35,31 @@ func TestEngine_ParseAndRenderString(t *testing.T) { }) } } + +func TestEngine_ParseAndRenderString_ptr_to_hash(t *testing.T) { + params := map[string]interface{}{ + "message": &map[string]interface{}{ + "Text": "hello", + }, + } + engine := NewEngine() + template := "{{ message.Text }}" + str, err := engine.ParseAndRenderString(template, params) + require.NoError(t, err) + require.Equal(t, "hello", str) +} + +type testStruct struct{ Text string } + +func TestEngine_ParseAndRenderString_struct(t *testing.T) { + params := map[string]interface{}{ + "message": testStruct{ + Text: "hello", + }, + } + engine := NewEngine() + template := "{{ message.Text }}" + str, err := engine.ParseAndRenderString(template, params) + require.NoError(t, err) + require.Equal(t, "hello", str) +}