- Introduced new endpoints for contact discovery, including scanning, listing, and managing discovered contacts. - Implemented retry logic for handling missing DAV credentials during contact operations. - Added public share functionality for drive API, allowing users to manage public shares, including upload, delete, and rename operations. - Updated Nextcloud configuration to support public share links and improved error handling for public share permissions. - Enhanced logging and validation across contact and drive APIs for better error tracking and user feedback. - Added tests for new contact matching and ranking functionalities to ensure accuracy and reliability.
40 lines
1022 B
Go
40 lines
1022 B
Go
package nextcloud
|
|
|
|
import "testing"
|
|
|
|
func TestFileMatchesQuery(t *testing.T) {
|
|
f := FileInfo{Name: "Report Q4.pdf", Path: "/Docs/Report Q4.pdf"}
|
|
if !fileMatchesQuery(f, "report") {
|
|
t.Fatal("expected name match")
|
|
}
|
|
if fileMatchesQuery(f, "missing") {
|
|
t.Fatal("expected no match")
|
|
}
|
|
}
|
|
|
|
func TestSortSearchResults_prefersNamePrefix(t *testing.T) {
|
|
files := []FileInfo{
|
|
{Name: "archive-report.pdf", Path: "/a/archive-report.pdf", Type: "file"},
|
|
{Name: "report.pdf", Path: "/b/report.pdf", Type: "file"},
|
|
}
|
|
sortSearchResults(files, "report")
|
|
if files[0].Name != "report.pdf" {
|
|
t.Fatalf("got %q, want report.pdf first", files[0].Name)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSearchPath(t *testing.T) {
|
|
if got := normalizeSearchPath("foo/bar/"); got != "/foo/bar" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestIsDirectoryEntry(t *testing.T) {
|
|
if !isDirectoryEntry(FileInfo{Type: "directory"}) {
|
|
t.Fatal("directory type")
|
|
}
|
|
if !isDirectoryEntry(FileInfo{MimeType: "httpd/unix-directory"}) {
|
|
t.Fatal("directory mime")
|
|
}
|
|
}
|