forked from verless/verless
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtpl_test.go
More file actions
42 lines (31 loc) · 911 Bytes
/
tpl_test.go
File metadata and controls
42 lines (31 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package tpl
import (
"path/filepath"
"testing"
"text/template"
"github.com/verless/verless/config"
"github.com/verless/verless/test"
)
const (
projectFolderPath = "../example"
testKey = "test key"
invalidKey = "invalid key"
)
func TestRegister(t *testing.T) {
pageTplPath := filepath.Join(projectFolderPath, config.TemplateDir, config.PageTpl)
_, err := Register(config.PageTpl, pageTplPath)
test.Ok(t, err)
_, err = Register(config.PageTpl, pageTplPath)
test.Assert(t, err != nil, "template has already been registered")
}
func TestGet(t *testing.T) {
if templates == nil {
templates = make(map[string]*template.Template)
}
templates[testKey] = &template.Template{}
tpl, err := Get(testKey)
test.Ok(t, err)
test.Assert(t, tpl == templates[testKey], "template has to be in map")
_, err = Get(invalidKey)
test.Assert(t, err != nil, "template key is invalid")
}