...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package couchserver
16
17 import (
18 "net/http/httptest"
19 "testing"
20
21 "gitlab.com/flimzy/testy"
22 )
23
24 func TestGetRoot(t *testing.T) {
25 h := Handler{
26 CompatVersion: "1.6.1",
27 Vendor: "Acme",
28 VendorVersion: "10.0",
29 }
30 w := httptest.NewRecorder()
31 req := httptest.NewRequest("GET", "/", nil)
32 handler := h.GetRoot()
33 handler(w, req)
34 resp := w.Result()
35 defer resp.Body.Close()
36 expected := map[string]interface{}{
37 "couchdb": "Välkommen",
38 "version": "1.6.1",
39 "vendor": map[string]string{
40 "version": "10.0",
41 "name": "Acme",
42 },
43 }
44 if d := testy.DiffAsJSON(expected, resp.Body); d != nil {
45 t.Error(d)
46 }
47 }
48
View as plain text