-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcpug_taiwan_test.go
53 lines (38 loc) · 1.17 KB
/
gcpug_taiwan_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
48
49
50
51
52
53
package main
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
)
func init() {
gin.SetMode(gin.TestMode)
}
func TestGetIndex(t *testing.T) {
assert := assert.New(t)
ts := GetMainEngine()
req, _ := http.NewRequest("GET", "/", nil)
w := httptest.NewRecorder()
ts.ServeHTTP(w, req)
assert.Equal(w.Code, 200)
assert.Contains(w.Body.String(), "Google Cloud Platform User Group Taiwan")
}
func TestIOIndex(t *testing.T) {
assert := assert.New(t)
ts := GetMainEngine()
req, _ := http.NewRequest("GET", "/io2016", nil)
w := httptest.NewRecorder()
ts.ServeHTTP(w, req)
assert.Equal(w.Code, 200)
assert.Contains(w.Body.String(), "<iframe src=\"https://events.google.com/io2016/embed\" style=\"width:1000px;height:700px\" frameborder=\"0\" allowfullscreen></iframe>")
}
func TestNoRoute(t *testing.T){
assert := assert.New(t)
ts := GetMainEngine()
req, _ := http.NewRequest("GET", "/noroute", nil)
w := httptest.NewRecorder()
ts.ServeHTTP(w, req)
assert.Equal(w.Code, 404)
assert.Contains(w.Body.String(), "<img src=\"/public/images/fox.jpg\" alt=\"Something to lighten your day\"></img>")
}