-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathui_test.go
46 lines (38 loc) · 1.14 KB
/
ui_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
package gitdb_test
import (
"net/http"
"testing"
)
func TestServer(t *testing.T) {
cfg := getConfig()
cfg.EnableUI = true
teardown := setup(t, cfg)
insert(getTestMessageWithId(1), false)
//fire off some requests
client := http.DefaultClient
requests := []*http.Request{
request(http.MethodGet, "http://localhost:4120/css/app.css"),
request(http.MethodGet, "http://localhost:4120/js/app.js"),
request(http.MethodGet, "http://localhost:4120/"),
request(http.MethodGet, "http://localhost:4120/errors/Message"),
request(http.MethodGet, "http://localhost:4120/list/Message"),
request(http.MethodGet, "http://localhost:4120/view/Message"),
request(http.MethodGet, "http://localhost:4120/view/Message/b0/r0"),
}
for _, req := range requests {
t.Logf("Testing %s", req.URL.String())
resp, err := client.Do(req)
if err != nil {
t.Errorf("GitDB UI Server request failed: %s", err)
}
//todo use golden files to check response
// b, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
// t.Log(string(b))
}
teardown(t)
}
func request(method, url string) *http.Request {
req, _ := http.NewRequest(method, url, nil)
return req
}