github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/genny/build/validate_test.go (about) 1 package build 2 3 import ( 4 "testing" 5 6 "github.com/gobuffalo/genny/v2/gentest" 7 "github.com/gobuffalo/packd" 8 "github.com/gobuffalo/packr/v2" 9 "github.com/stretchr/testify/require" 10 ) 11 12 var goodTemplates = func() packd.Box { 13 box := packd.NewMemoryBox() 14 box.AddString("_ignored/c.html", "c") 15 box.AddString("a.html", "a") 16 box.AddString("b.md", "b") 17 return box 18 }() 19 20 func Test_TemplateValidator_Good(t *testing.T) { 21 r := require.New(t) 22 23 tvs := []TemplateValidator{PlushValidator} 24 25 run := gentest.NewRunner() 26 run.WithRun(ValidateTemplates(goodTemplates, tvs)) 27 28 r.NoError(run.Run()) 29 } 30 31 func Test_TemplateValidator_Bad(t *testing.T) { 32 r := require.New(t) 33 34 box := packr.New("../build/_fixtures/template_validator/bad", "../build/_fixtures/template_validator/bad") 35 tvs := []TemplateValidator{PlushValidator} 36 37 run := gentest.NewRunner() 38 run.WithRun(ValidateTemplates(box, tvs)) 39 40 err := run.Run() 41 r.Error(err) 42 r.Equal("template error in file a.html: line 1: no prefix parse function for > found\ntemplate error in file b.md: line 1: no prefix parse function for > found", err.Error()) 43 }