github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/render/plain_test.go (about)

     1  package render
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  
     7  	"github.com/gobuffalo/packd"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func Test_Plain(t *testing.T) {
    12  	r := require.New(t)
    13  
    14  	box := packd.NewMemoryBox()
    15  	r.NoError(box.AddString("test.txt", "<%= name %>"))
    16  
    17  	e := NewEngine()
    18  	e.TemplatesBox = box
    19  
    20  	re := e.Plain("test.txt")
    21  	r.Equal("text/plain; charset=utf-8", re.ContentType())
    22  
    23  	var examples = []string{"Mark", "Jém"}
    24  	for _, example := range examples {
    25  		example := example
    26  		bb := &bytes.Buffer{}
    27  		r.NoError(re.Render(bb, Data{"name": example}))
    28  		r.Equal(example, bb.String())
    29  	}
    30  }