almost there
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestServerRoutes(t *testing.T) {
|
||||
server := NewServer(t.TempDir())
|
||||
if err := server.Routes(); err != nil {
|
||||
@@ -11,15 +18,16 @@ func TestServerRoutes(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ensureAndWrite(server.diskMediaPath("delid"), []byte("hi"))
|
||||
ensureAndWrite(server.diskFilePath("getfid"), []byte("getfid body"))
|
||||
ensureAndWrite(server.diskFilePath("putfid"), []byte("initial putfid body"))
|
||||
ensureAndWrite(server.diskFilePath("delfid"), []byte("delfid body"))
|
||||
ensureAndWrite(path.Join(server.root, "index.html"), []byte("mom"))
|
||||
if err := server.tree().Put("putfid", Branch{}); err != nil {
|
||||
|
||||
tree := server.tree()
|
||||
if err := tree.Put([]string{"getfid"}, Leaf{Title: "", Content: "getfid body"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
server.tree().Put("delfid", Branch{Title: "delfid title"})
|
||||
server.tree().Put("getfid", Branch{Title: "getfid title"})
|
||||
tree.Put([]string{"putfid"}, Leaf{Title: "putfid title", Content: "initial putfid body"})
|
||||
tree.Put([]string{"delfid"}, Leaf{Title: "delfid title", Content: "delfid body"})
|
||||
t.Log(tree.GetRoot())
|
||||
|
||||
ensureAndWrite(path.Join(server.root, "index.html"), []byte("mom"))
|
||||
|
||||
cases := map[string]struct {
|
||||
path string
|
||||
@@ -37,15 +45,10 @@ func TestServerRoutes(t *testing.T) {
|
||||
method: http.MethodGet,
|
||||
want: `["getfid"]`,
|
||||
},
|
||||
"v0: tree: get pretty": {
|
||||
path: "/api/v0/tree?pretty",
|
||||
method: http.MethodGet,
|
||||
want: `"getfid":{"Children":{`,
|
||||
},
|
||||
"v0: tree: get": {
|
||||
path: "/api/v0/tree",
|
||||
method: http.MethodGet,
|
||||
want: `":{"Title":"getfid title",`,
|
||||
want: `"Title":"Untitled",`,
|
||||
},
|
||||
"v0: media: post": {
|
||||
path: "/api/v0/media",
|
||||
@@ -101,6 +104,7 @@ func TestServerRoutes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestServerPutTreeGetFile(t *testing.T) {
|
||||
server := NewServer(t.TempDir())
|
||||
if err := server.Routes(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user