Ejemplo n.º 1
0
func TestTemplateAllFieldsPlusOneNotRecognized(t *testing.T) {
	log.TurnOnLogging()
	option := "template={{.Success }} {{ .Error }} {{ .Expected }}, {{ .Actual }},{{ .Url }}, {{ .Label }} {{ .WHAT }}"
	expected := "true <nil> hello, hello,http://hello/world, my label "
	formatter := NewTemplateResultFormatter(option, emptyModifiersForTesting)
	result := NewResult(true, nil, "hello", "hello", "http://hello/world", "my label")
	reader := formatter.Reader(result)
	assert.Equal(t, expected, readerToString(reader))
}
Ejemplo n.º 2
0
func TestTemplateConditional(t *testing.T) {
	log.TurnOnLogging()
	option := `template=[ {{if .Success}}ok{{else}}fail{{end}} ] {{ .Label }}, {{ .Url}}
Expected {{ .Expected }}; Got {{ .Actual }}`
	expected := "[ ok ] my label, http://hello/world\nExpected hello; Got hello"
	formatter := NewTemplateResultFormatter(option, emptyModifiersForTesting)
	result := NewResult(true, nil, "hello", "hello", "http://hello/world", "my label")
	reader := formatter.Reader(result)
	assert.Equal(t, expected, readerToString(reader))
}