-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathrender_test.go
43 lines (35 loc) · 983 Bytes
/
render_test.go
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
43
package baa
import (
"net/http"
"net/http/httptest"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestRender1(t *testing.T) {
Convey("response method", t, func() {
b.Get("/render", func(c *Context) {
c.Set("name", "Baa")
c.HTML(200, "_fixture/index1.html")
})
b.Get("/render2", func(c *Context) {
c.Set("name", "Baa")
c.HTML(200, "_fixture/index2.html")
})
b.Get("/render3", func(c *Context) {
c.Set("name", "Baa")
c.HTML(200, "_fixture/index3.html")
})
req, _ := http.NewRequest("GET", "/render", nil)
w := httptest.NewRecorder()
b.ServeHTTP(w, req)
So(w.Code, ShouldEqual, http.StatusOK)
req, _ = http.NewRequest("GET", "/render2", nil)
w = httptest.NewRecorder()
b.ServeHTTP(w, req)
So(w.Code, ShouldEqual, http.StatusInternalServerError)
req, _ = http.NewRequest("GET", "/render3", nil)
w = httptest.NewRecorder()
b.ServeHTTP(w, req)
So(w.Code, ShouldEqual, http.StatusInternalServerError)
})
}