Files
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

53 lines
1.5 KiB
Go

package userproject
import (
"path/filepath"
"testing"
storesqlite "github.com/tutti-os/tutti/packages/agent/store-sqlite"
)
func TestSectionKeyFromPathMatchesRailClassification(t *testing.T) {
rawDir := t.TempDir()
canonicalDir := storesqlite.NormalizeProjectPath(rawDir)
if canonicalDir == "" {
t.Fatal("normalized temp dir is empty")
}
gotRaw := SectionKeyFromPath(rawDir)
gotCanonical := SectionKeyFromPath(canonicalDir)
want := storesqlite.RailSectionKeyForProject(rawDir)
if gotRaw != want {
t.Fatalf("SectionKeyFromPath(raw) = %q, want %q", gotRaw, want)
}
if gotCanonical != want {
t.Fatalf("SectionKeyFromPath(canonical) = %q, want %q", gotCanonical, want)
}
if canonicalDir != rawDir && gotRaw == "project:"+rawDir {
t.Fatalf("SectionKeyFromPath must normalize symlink forms, got %q", gotRaw)
}
if gotRaw != "project:"+filepath.Clean(canonicalDir) &&
gotRaw != storesqlite.RailSectionKeyForProject(canonicalDir) {
t.Fatalf("unexpected section key %q for %q", gotRaw, rawDir)
}
}
func TestSectionKeyFromPathEmpty(t *testing.T) {
if got := SectionKeyFromPath(" "); got != "" {
t.Fatalf("empty path section key = %q, want empty", got)
}
}
func TestLabelFromPathSupportsWindowsAndPOSIXSeparators(t *testing.T) {
tests := map[string]string{
"/workspace/tutti/": "tutti",
`C:\Users\demo\Documents\tutti`: "tutti",
`C:\Users\demo\Documents\tutti\`: "tutti",
}
for path, want := range tests {
if got := LabelFromPath(path); got != want {
t.Errorf("LabelFromPath(%q) = %q, want %q", path, got, want)
}
}
}