test tree foreach

This commit is contained in:
Bel LaPointe
2022-02-16 08:05:14 -07:00
parent 63caf9ed03
commit a7c8a0d481
5 changed files with 39 additions and 16 deletions

View File

@@ -31,11 +31,11 @@ func TestServerRoutes(t *testing.T) {
ensureAndWrite(server.diskMediaPath("delid"), []byte("hi"))
tree := server.tree()
if err := tree.Put(ID("getfid"), Leaf{Title: "", Content: "getfid body"}); err != nil {
if err := tree.Put(NewID("getfid"), Leaf{Title: "", Content: "getfid body"}); err != nil {
t.Fatal(err)
}
tree.Put(ID("putfid"), Leaf{Title: "putfid title", Content: "initial putfid body"})
tree.Put(ID("delfid"), Leaf{Title: "delfid title", Content: "delfid body"})
tree.Put(NewID("putfid"), Leaf{Title: "putfid title", Content: "initial putfid body"})
tree.Put(NewID("delfid"), Leaf{Title: "delfid title", Content: "delfid body"})
t.Log(tree.GetRoot())
ensureAndWrite(path.Join(server.root, "index.html"), []byte("mom"))
@@ -151,7 +151,7 @@ func TestServerPutTreeGetFile(t *testing.T) {
if err := server.Routes(); err != nil {
t.Fatal(err)
}
server.tree().Put(ID("my pid"), Leaf{})
server.tree().Put(NewID("my pid"), Leaf{})
var id string
t.Run("put to create an id", func(t *testing.T) {
r := httptest.NewRequest(http.MethodPut, "/my%20pid/my-put-id", strings.NewReader("body"))