40 lines
1.2 KiB
Go
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)
|
|
}
|
|
}
|