-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_test.go
56 lines (44 loc) · 863 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
48
49
50
51
52
53
54
55
56
package main
import (
"net/http"
"net/http/httptest"
"net/url"
"os"
"reflect"
"testing"
)
func TestMain(m *testing.M) {
// setup()
code := m.Run()
// teardown()
os.Exit(code)
}
var (
repo *Repo
server *httptest.Server
mux *http.ServeMux
)
func Setup() {
os.Setenv("GHS_PRINT", "no")
mux = http.NewServeMux()
server = httptest.NewServer(mux)
}
func Teardown() {
server.Close()
}
func testMethod(t *testing.T, r *http.Request, want string) {
if got := r.Method; got != want {
t.Errorf("Request method: %v, want %v", got, want)
}
}
type values map[string]string
func testFormValues(t *testing.T, r *http.Request, values values) {
want := url.Values{}
for k, v := range values {
want.Add(k, v)
}
r.ParseForm()
if got := r.Form; !reflect.DeepEqual(got, want) {
t.Errorf("Request parameters: %v, want %v", got, want)
}
}