1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-26 22:34:44 +01:00

Add top-level test cases for &map, struct

The are from #23
This commit is contained in:
Oliver Steele 2017-07-21 11:35:11 -04:00
parent c94902613d
commit f670bfcb13

View File

@ -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)
}