Skip to content

Commit

Permalink
Test Missing Template Or Name
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Dec 21, 2016
1 parent f5f6e6b commit ce2733d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions multitemplate_test.go
@@ -1,6 +1,7 @@
package multitemplate

import (
"html/template"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -37,6 +38,18 @@ func createFromString() Render {
return r
}

func TestMissingTemplateOrName(t *testing.T) {
r := New()
tmpl := template.Must(template.New("test").Parse("Welcome to {{ .name }} template"))
assert.Panics(t, func() {
r.Add("", tmpl)
}, "template name cannot be empty")

assert.Panics(t, func() {
r.Add("test", nil)
}, "template can not be nil")
}

func TestAddFromFiles(t *testing.T) {
router := gin.New()
router.HTMLRender = createFromFile()
Expand Down

0 comments on commit ce2733d

Please sign in to comment.