Add background mount path helpers

This commit is contained in:
Jan Bader
2026-07-19 19:48:49 +02:00
parent ef8caef37b
commit 7edd1b8d7f
5 changed files with 227 additions and 12 deletions
+22
View File
@@ -2,6 +2,7 @@ package main
import (
"context"
"path/filepath"
"testing"
"bazil.org/fuse"
@@ -36,6 +37,27 @@ func TestBuildMountTreeGroupsByFolderAndDate(t *testing.T) {
}
}
func TestItemIDFromURLOrID(t *testing.T) {
if got := itemIDFromURLOrID("https://docspell.example/app/item/item-123"); got != "item-123" {
t.Fatalf("expected item-123, got %q", got)
}
if got := itemIDFromURLOrID("item-456"); got != "item-456" {
t.Fatalf("expected raw id, got %q", got)
}
}
func TestItemIDFromLocalByIDPath(t *testing.T) {
mountPath := t.TempDir()
path := filepath.Join(mountPath, "by-id", "it", "item-1.pdf")
got, err := itemIDFromLocalPath(path, config{MountPath: mountPath})
if err != nil {
t.Fatal(err)
}
if got != "item-1" {
t.Fatalf("expected item-1, got %q", got)
}
}
func TestBuildMountTreeDeduplicatesAttachmentNames(t *testing.T) {
items := []SearchItem{{
ID: "item-1",