-
Notifications
You must be signed in to change notification settings - Fork 17
/
rest_test.go
52 lines (42 loc) · 938 Bytes
/
rest_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
package main
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestHome(t *testing.T) {
ts := httptest.NewServer(httpEngine())
defer ts.Close()
resp, err := http.Get(ts.URL + "/")
defer resp.Body.Close()
if err != nil {
t.Fatal(err)
}
if resp.StatusCode != 200 {
t.Errorf("unexpected status code: %v", resp.StatusCode)
}
}
func TestAdmin(t *testing.T) {
ts := httptest.NewServer(httpEngine())
defer ts.Close()
resp, err := http.Get(ts.URL + "/admin")
defer resp.Body.Close()
if err != nil {
t.Fatal(err)
}
if resp.StatusCode != 200 {
t.Errorf("unexpected status code: %v", resp.StatusCode)
}
}
func TestStatic(t *testing.T) {
ts := httptest.NewServer(httpEngine())
defer ts.Close()
resp, err := http.Get(ts.URL + "/static/js/timeline.js")
defer resp.Body.Close()
if err != nil {
t.Fatal(err)
}
if resp.StatusCode != 200 {
t.Errorf("unexpected status code: %v", resp.StatusCode)
}
}