11 "github.com/stretchr/testify/assert"
14func TestLoadTemplates(t *testing.T) {
18 TestString: "Testing",
21 templates := loadTemplates("")
22 assert.NotEqual(t, templates, nil)
24 var defaultSignin bytes.Buffer
25 templates.ExecuteTemplate(&defaultSignin, "sign_in.html", data)
26 assert.Equal(t, "\n<!DOCTYPE html>", defaultSignin.String()[0:16])
28 var defaultError bytes.Buffer
29 templates.ExecuteTemplate(&defaultError, "error.html", data)
30 assert.Equal(t, "\n<!DOCTYPE html>", defaultError.String()[0:16])
32 dir, err := ioutil.TempDir("", "templatetest")
36 defer os.RemoveAll(dir)
38 templateHTML := `{{.TestString}} {{.TestString | ToLower}} {{.TestString | ToUpper}}`
39 signInFile := filepath.Join(dir, "sign_in.html")
40 if err := ioutil.WriteFile(signInFile, []byte(templateHTML), 0666); err != nil {
43 errorFile := filepath.Join(dir, "error.html")
44 if err := ioutil.WriteFile(errorFile, []byte(templateHTML), 0666); err != nil {
47 templates = loadTemplates(dir)
48 assert.NotEqual(t, templates, nil)
50 var sitpl bytes.Buffer
51 templates.ExecuteTemplate(&sitpl, "sign_in.html", data)
52 assert.Equal(t, "Testing testing TESTING", sitpl.String())
54 var errtpl bytes.Buffer
55 templates.ExecuteTemplate(&errtpl, "error.html", data)
56 assert.Equal(t, "Testing testing TESTING", errtpl.String())
59func TestTemplatesCompile(t *testing.T) {
60 templates := getTemplates()
61 assert.NotEqual(t, templates, nil)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list