Example #1
0
func TestOutputWithAnEscapeParameter(t *testing.T) {
	output, err := newOutput(core.NewParser([]byte("{{'fun' | debug: 'te\\'st'}}")))
	assert.Nil(t, err)
	assertFilters(t, output, "debug(0, te'st)")
}
Example #2
0
func TestOutputWithMultipleFilters(t *testing.T) {
	output, _ := newOutput(core.NewParser([]byte("{{'fun' | debug | debug}}")))
	assertFilters(t, output, "debug(0)", "debug(1)")
}
Example #3
0
func TestOutputWithMultipleFiltersHavingParameters(t *testing.T) {
	output, err := newOutput(core.NewParser([]byte("{{'fun' | debug:1,2 | debug:'test' | debug : 'test' , 5}}")))
	assert.Nil(t, err)
	assertFilters(t, output, "debug(0, 1, 2)", "debug(1, test)", "debug(2, test, 5)")
}
Example #4
0
func TestOutputGeneratesErrorOnUnknownFilter(t *testing.T) {
	_, err := newOutput(core.NewParser([]byte("{{'fun' | unknown }}")))
	assert.Nil(t, err)
	//assert.Equal(t, err.Error(), `Unknown filter "unknown" ("{{'fun' | unknown }}" - line 1)`)
}
Example #5
0
func TestOutputGeneratesErrorOnInvalidParameter(t *testing.T) {
	_, err := newOutput(core.NewParser([]byte("{{'fun' | debug: 'missing }}")))
	assert.Equal(t, err.Error(), `Invalid value, a single quote might be missing ("{{'fun' | debug: 'missing }}" - line 1)`)
}
Example #6
0
func TestOutputExtractionGivesErrorForUnclosedStatic(t *testing.T) {
	output, err := newOutput(core.NewParser([]byte("{{ 'failure }}")))
	assert.Nil(t, output)
	assert.Equal(t, err.Error(), `Invalid value, a single quote might be missing ("{{ 'failure }}" - line 1)`)
}
Example #7
0
func TestOutputNoFiltersForStatic(t *testing.T) {
	output, _ := newOutput(core.NewParser([]byte("{{'fun'}}")))
	assert.Equal(t, len(output.(*Output).Filters), 0)
}
Example #8
0
func TestOutputExtractsAStaticWithAnEndingQuote(t *testing.T) {
	output, _ := newOutput(core.NewParser([]byte("{{'it\\''}}")))
	assertRender(t, output, nil, "it'")
}
Example #9
0
func TestOutputExtractsAComplexStatic(t *testing.T) {
	output, _ := newOutput(core.NewParser([]byte("{{'it\\'s over \\9000'}}")))
	assertRender(t, output, nil, "it's over \\9000")
}
Example #10
0
func TestOutputExtractsASimpleStatic(t *testing.T) {
	output, _ := newOutput(core.NewParser([]byte("{{  'over 9000'}}")))
	assertRender(t, output, nil, "over 9000")
}
Example #11
0
func TestOutputHandlesSpaceOnlyOutput(t *testing.T) {
	output, err := newOutput(core.NewParser([]byte("{{   }}")))
	assert.Nil(t, output)
	assert.Nil(t, err)
}
Example #12
0
func newParser(s string) *core.Parser {
	return core.NewParser([]byte(s))
}