server stubs /ui/files and /ui/search
This commit is contained in:
@@ -17,6 +17,14 @@ func TestServerRoutes(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := ensureAndWrite(path.Join(server.root, "ui", "files.ctmpl"), []byte(`{{ define "files" }}{{ template "_import" }}HI FROM FILES{{ end }}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if err := ensureAndWrite(path.Join(server.root, "ui", "search.ctmpl"), []byte(`{{ define "search" }}{{ template "_import" }}HI FROM SEARCH{{ end }}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if err := ensureAndWrite(path.Join(server.root, "ui", "templates", "_import.ctmpl"), []byte(`{{ define "_import" }}HI FROM IMPORT{{ end }}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := ensureAndWrite(server.diskMediaPath("id"), []byte("hi")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -41,7 +49,7 @@ func TestServerRoutes(t *testing.T) {
|
||||
"v0: /: get": {
|
||||
path: "/",
|
||||
method: http.MethodGet,
|
||||
want: "mom",
|
||||
want: "Moved",
|
||||
},
|
||||
"v0: search: get": {
|
||||
path: "/api/v0/search?q=getf%20bod",
|
||||
@@ -85,6 +93,37 @@ func TestServerRoutes(t *testing.T) {
|
||||
path: "/api/v0/files/delfid",
|
||||
method: http.MethodDelete,
|
||||
},
|
||||
"v0: /: redir": {
|
||||
path: "/",
|
||||
method: http.MethodGet,
|
||||
want: "Moved",
|
||||
},
|
||||
"v0: /ui/: redir": {
|
||||
path: "/ui/",
|
||||
method: http.MethodGet,
|
||||
want: "Moved",
|
||||
},
|
||||
"v0: /ui: redir": {
|
||||
path: "/ui",
|
||||
method: http.MethodGet,
|
||||
want: "Moved",
|
||||
},
|
||||
"v0: /ui/search": {
|
||||
path: "/ui/search",
|
||||
method: http.MethodGet,
|
||||
},
|
||||
"v0: /ui/search?q=abc": {
|
||||
path: "/ui/search?q=abc",
|
||||
method: http.MethodGet,
|
||||
},
|
||||
"v0: /ui/files/getfid": {
|
||||
path: "/ui/files/getfid",
|
||||
method: http.MethodGet,
|
||||
},
|
||||
"v0: /ui/files": {
|
||||
path: "/ui/files",
|
||||
method: http.MethodGet,
|
||||
},
|
||||
}
|
||||
|
||||
for name, d := range cases {
|
||||
@@ -96,7 +135,7 @@ func TestServerRoutes(t *testing.T) {
|
||||
if w.Code == http.StatusNotFound {
|
||||
t.Fatal(w)
|
||||
}
|
||||
if w.Code != http.StatusOK {
|
||||
if w.Code >= 400 {
|
||||
t.Fatal(w)
|
||||
}
|
||||
if len(c.want) > 0 && !strings.Contains(string(w.Body.Bytes()), c.want) {
|
||||
|
||||
Reference in New Issue
Block a user