Merge pull request #99 from yxxhero/add_e2e_tmpl_test

add e2e tmpl test
This commit is contained in:
Yusuke Kuoka
2022-06-05 13:23:08 +09:00
committed by GitHub
7 changed files with 269 additions and 1 deletions
+9
View File
@@ -5,3 +5,12 @@ type Context struct {
basePath string
readFile func(string) ([]byte, error)
}
// SetBasePath sets the base path for the template
func (c *Context) SetBasePath(path string) {
c.basePath = path
}
func (c *Context) SetReadFile(f func(string) ([]byte, error)) {
c.readFile = f
}
+4
View File
@@ -172,6 +172,10 @@ func (c *Context) ReadFile(filename string) (string, error) {
path = filepath.Join(c.basePath, filename)
}
if c.readFile == nil {
return "", fmt.Errorf("readFile is not implemented")
}
bytes, err := c.readFile(path)
if err != nil {
return "", err