Add by-id mount directory
This commit is contained in:
@@ -70,3 +70,26 @@ func TestFileNodeUnknownSizeDoesNotAdvertiseZeroLength(t *testing.T) {
|
||||
t.Fatal("expected unknown size before download")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildMountTreeAddsByIDDirectory(t *testing.T) {
|
||||
items := []SearchItem{{
|
||||
ID: "item-1",
|
||||
Name: "Invoice",
|
||||
Attachments: []ItemAttachment{
|
||||
{ID: "att-1", Name: "original.pdf"},
|
||||
{ID: "att-2", Name: "extra.txt"},
|
||||
{ID: "att-3", Name: "scan.pdf"},
|
||||
},
|
||||
}}
|
||||
|
||||
root := buildMountTree(context.Background(), &DocspellClient{}, items)
|
||||
byID, ok := root.children["by-id"].(*dirNode)
|
||||
if !ok {
|
||||
t.Fatalf("expected by-id directory, got %#v", root.children)
|
||||
}
|
||||
for _, name := range []string{"item-1.pdf", "item-1-2.txt", "item-1-3.pdf"} {
|
||||
if _, ok := byID.children[name].(*fileNode); !ok {
|
||||
t.Fatalf("expected %s in by-id, got %#v", name, byID.children)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user