impl http api server for serving index.html, api calls
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"path"
|
||||
@@ -37,8 +36,9 @@ func TestServerRoutes(t *testing.T) {
|
||||
want: "mom",
|
||||
},
|
||||
"v0: search: get": {
|
||||
path: "/api/v0/search",
|
||||
path: "/api/v0/search?q=getf%20bod",
|
||||
method: http.MethodGet,
|
||||
want: `["getfid"]`,
|
||||
},
|
||||
"v0: tree: get": {
|
||||
path: "/api/v0/tree",
|
||||
@@ -88,15 +88,13 @@ func TestServerRoutes(t *testing.T) {
|
||||
if w.Code == http.StatusNotFound {
|
||||
t.Fatal(w)
|
||||
}
|
||||
if !bytes.HasPrefix(w.Body.Bytes(), []byte("not impl")) {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatal(w)
|
||||
}
|
||||
if len(c.want) > 0 && !strings.Contains(string(w.Body.Bytes()), c.want) {
|
||||
t.Fatal(w)
|
||||
}
|
||||
t.Logf("%s %s (%+v) => %s", c.method, c.path, w.Header(), w.Body.Bytes())
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatal(w)
|
||||
}
|
||||
if len(c.want) > 0 && !strings.Contains(string(w.Body.Bytes()), c.want) {
|
||||
t.Fatal(w)
|
||||
}
|
||||
t.Logf("%s %s (%+v) => %s", c.method, c.path, w.Header(), w.Body.Bytes())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user