ultisuite-backend/internal/nextcloud/public_share_binding_test.go
R3D347HR4Y d4ccf7eb6e
Some checks are pending
CI / Go tests (push) Waiting to run
CI / Integration tests (push) Waiting to run
CI / DB migrations (push) Waiting to run
hocuspocus lol 2
2026-06-09 14:30:34 +02:00

40 lines
1.2 KiB
Go

package nextcloud
import "testing"
func TestPublicShareBindingClientSourcePath(t *testing.T) {
b := &PublicShareBinding{
SharePath: "/Documents/hello.docx",
ItemType: "file",
}
if got := b.ClientSourcePath("/", ""); got != "/hello.docx" {
t.Fatalf("single file empty display: got %q", got)
}
if got := b.ClientSourcePath("/hello.docx", ""); got != "/hello.docx" {
t.Fatalf("explicit path: got %q", got)
}
folder := &PublicShareBinding{SharePath: "/Documents", ItemType: "folder"}
if got := folder.ClientSourcePath("/", "notes.txt"); got != "/notes.txt" {
t.Fatalf("folder root display: got %q", got)
}
}
func TestPublicShareBindingOwnerPathForClient(t *testing.T) {
b := &PublicShareBinding{
SharePath: "/Documents/hello.docx",
ItemType: "file",
}
if got := b.OwnerPathForClient("/", ""); got != "/Documents/hello.docx" {
t.Fatalf("source owner path: got %q", got)
}
if got := b.OwnerPathForClient("/hello.ultidoc.json", ""); got != "/Documents/hello.ultidoc.json" {
t.Fatalf("sidecar owner path: got %q", got)
}
folder := &PublicShareBinding{SharePath: "/Documents", ItemType: "folder"}
if got := folder.OwnerPathForClient("/hello.docx", ""); got != "/Documents/hello.docx" {
t.Fatalf("folder file owner path: got %q", got)
}
}