Files
pages/internal/store/path_completion_test.go
Anya Tokugawa d5d21b7841
Build and publish container images / images (push) Successful in 9m34s
Release container images / release (push) Successful in 36s
Refactor architecture into eight components and consolidate reliability work
Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts.

Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation.

Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
2026-11-01 15:23:31 +09:00

39 lines
1.5 KiB
Go

package store
import (
"context"
"testing"
)
func TestPathCompletionNamesNoRevisionsAndBounded(t *testing.T) {
s := newSchemaTestStore(t)
// Deliberately omit revisions and documents: completion must never hydrate them.
_, err := s.DB.Exec(`CREATE TABLE paths(domain_uuid TEXT,path TEXT,object_uuid TEXT);
INSERT INTO paths VALUES('d','/docs/日本語 #?/child','o'),('d','/docs/a%b','o'),('d','/docs/a_b','o'),('other','/docs/secret','o'),('d','/docs-other/no','o');`)
if err != nil {
t.Fatal(err)
}
for _, prefix := range []string{"日本", "a%", "a_"} {
entries, more, err := s.ListPathCompletionNames(context.Background(), "d", "/docs", prefix)
if err != nil || more || len(entries) != 1 {
t.Fatalf("%q: %+v more=%v err=%v", prefix, entries, more, err)
}
if prefix == "日本" && (!entries[0].IsDir || entries[0].Path != "/docs/日本語 #?") {
t.Fatal(entries)
}
}
_, err = s.DB.Exec(`WITH RECURSIVE n(v) AS (VALUES(1) UNION ALL SELECT v+1 FROM n WHERE v<1200) INSERT INTO paths SELECT 'd','/many/'||printf('%04d',v),'o' FROM n`)
if err != nil {
t.Fatal(err)
}
entries, more, err := s.ListPathCompletionNames(context.Background(), "d", "/many", "")
if err != nil || !more || len(entries) != 1000 {
t.Fatalf("budget: %d %v %v", len(entries), more, err)
}
ctx, cancel := context.WithCancel(context.Background())
cancel()
if _, _, err = s.ListPathCompletionNames(ctx, "d", "/many", ""); err == nil {
t.Fatal("ignored cancellation")
}
}