-
-
Notifications
You must be signed in to change notification settings - Fork 175
/
main_test.go
47 lines (36 loc) · 864 Bytes
/
main_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
44
45
46
47
package main
import (
"fmt"
"testing"
"github.com/kataras/iris/v12/httptest"
)
func TestResponseWriterQuicktemplate(t *testing.T) {
baseRawBody := `
<html>
<head>
<title>Quicktemplate integration with Iris</title>
</head>
<body>
<div>
Header contents here...
</div>
<div style="margin:10px;">
<h1>%s</h1>
<div>
%s
</div>
</div>
</body>
<footer>
Footer contents here...
</footer>
</html>
`
expectedIndexRawBody := fmt.Sprintf(baseRawBody, "Index Page", "This is our index page's body.")
name := "yourname"
expectedHelloRawBody := fmt.Sprintf(baseRawBody, "Hello World!", "Hello <b>"+name+"!</b>")
app := newApp()
e := httptest.New(t, app)
e.GET("/").Expect().Status(httptest.StatusOK).Body().IsEqual(expectedIndexRawBody)
e.GET("/" + name).Expect().Status(httptest.StatusOK).Body().IsEqual(expectedHelloRawBody)
}