Add unit tests for LoadHTML in debug mode

This commit is contained in:
Manu Mtz-Almeida 2015-07-04 20:06:40 +02:00
parent 0e08a109f9
commit 638377655d
1 changed files with 20 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/gin-gonic/gin/render"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -27,6 +28,25 @@ func TestCreateEngine(t *testing.T) {
assert.Empty(t, router.Handlers) assert.Empty(t, router.Handlers)
} }
func TestLoadHTMLDebugMode(t *testing.T) {
router := New()
SetMode(DebugMode)
router.LoadHTMLGlob("*")
r := router.HTMLRender.(render.HTMLDebug)
assert.Empty(t, r.Files)
assert.Equal(t, r.Glob, "*")
router.LoadHTMLFiles("index.html", "login.html")
r = router.HTMLRender.(render.HTMLDebug)
assert.Empty(t, r.Glob)
assert.Equal(t, r.Files, []string{"index.html", "login.html"})
SetMode(TestMode)
}
func TestLoadHTMLReleaseMode(t *testing.T) {
}
func TestAddRoute(t *testing.T) { func TestAddRoute(t *testing.T) {
router := New() router := New()
router.addRoute("GET", "/", HandlersChain{func(_ *Context) {}}) router.addRoute("GET", "/", HandlersChain{func(_ *Context) {}})