From 88563f9d78f6106c8c7daca850e43ed1e0e939ac Mon Sep 17 00:00:00 2001 From: thinkerou Date: Thu, 16 Nov 2017 21:05:54 +0800 Subject: [PATCH] add release mode cases --- gin_test.go | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/gin_test.go b/gin_test.go index 1a7afba6..57985dce 100644 --- a/gin_test.go +++ b/gin_test.go @@ -80,7 +80,6 @@ func setupHTMLGlob(t *testing.T, mode string, tls bool) func() { return func() {} } -//TODO func TestLoadHTMLGlob(t *testing.T) { td := setupHTMLGlob(t, DebugMode, false) res, err := http.Get("http://127.0.0.1:8888/test") @@ -107,6 +106,19 @@ func TestLoadHTMLGlob2(t *testing.T) { td() } +func TestLoadHTMLGlob3(t *testing.T) { + td := setupHTMLGlob(t, ReleaseMode, false) + res, err := http.Get("http://127.0.0.1:8888/test") + if err != nil { + fmt.Println(err) + } + + resp, _ := ioutil.ReadAll(res.Body) + assert.Equal(t, "

Hello world

", string(resp[:])) + + td() +} + func TestLoadHTMLGlobUsingTLS(t *testing.T) { td := setupHTMLGlob(t, DebugMode, true) // Use InsecureSkipVerify for avoiding `x509: certificate signed by unknown authority` error @@ -191,6 +203,18 @@ func TestLoadHTMLFiles2(t *testing.T) { td() } +func TestLoadHTMLFiles3(t *testing.T) { + td := setupHTMLFiles(t, ReleaseMode, false) + res, err := http.Get("http://127.0.0.1:8888/test") + if err != nil { + fmt.Println(err) + } + + resp, _ := ioutil.ReadAll(res.Body) + assert.Equal(t, "

Hello world

", string(resp[:])) + td() +} + func TestLoadHTMLFilesUsingTLS(t *testing.T) { td := setupHTMLFiles(t, TestMode, true) // Use InsecureSkipVerify for avoiding `x509: certificate signed by unknown authority` error @@ -224,10 +248,6 @@ func TestLoadHTMLFilesFuncMap(t *testing.T) { td() } -func TestLoadHTMLReleaseMode(t *testing.T) { - -} - func TestAddRoute(t *testing.T) { router := New() router.addRoute("GET", "/", HandlersChain{func(_ *Context) {}})