There is no need for the rakyll/statik package starting with Go 1.16, which provides us with tools for embedding files without third-party libraries.
18 lines
326 B
Go
18 lines
326 B
Go
package templates
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_Read(t *testing.T) {
|
|
file, err := Read("testdata/template.html.tmpl")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, []byte("template\n"), file)
|
|
|
|
file, err = Read("testdata/bad_path.html.tmpl")
|
|
assert.Error(t, err)
|
|
assert.Nil(t, file)
|
|
}
|