feat: scaffold codespace backend

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
tao.chen
2026-07-02 15:07:54 +08:00
co-authored by Claude Fable 5
commit 411ed1f8ba
43 changed files with 4428 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
package workspace
import (
"testing"
)
func TestValidIDAcceptsSafeSegments(t *testing.T) {
valid := []string{"user1", "project-A", "project_A", "project.1"}
for _, id := range valid {
if !ValidID(id) {
t.Errorf("expected ValidID(%q) to be true", id)
}
}
}
func TestValidIDRejectsUnsafeSegments(t *testing.T) {
invalid := []string{"", ".", "..", "/tmp/x", "../x", "a/b", "a b", "中文", "*"}
for _, id := range invalid {
if ValidID(id) {
t.Errorf("expected ValidID(%q) to be false", id)
}
}
}
func TestRootForUsesConfiguredRoot(t *testing.T) {
got := RootFor("/tmp/workspaces", "user1")
want := "/tmp/workspaces/user1"
if got != want {
t.Errorf("RootFor = %q, want %q", got, want)
}
}