bc218dfbbe
* feat: add workspace sources from files panel * fix: preserve worktree identity during recovery * feat: unify workspace source actions * fix: validate recovered workspace repositories * fix: harden workspace source filesystem boundaries * test: split workspace repository chip coverage * fix: restrict repository rescan recovery paths * fix: stabilize workspace source CI checks * test: canonicalize workspace source paths * test: align workspace source container paths * fix: populate direct workspace repository names * test: preserve git fixture rewrites across restarts * test: isolate backend git fixture config * fix: resume remote workspace executions before creation * fix: preserve ssh agent identity during resume * fix: preserve SSH workspace across backend restart * fix: simplify workspace actions trigger * fix: refine add workspace repositories UX * docs: narrow workspace source UX updates * fix: avoid phantom turn on session resume * test(web): normalize workspace source request headers * feat(web): streamline workspace source picker * docs: remove trailing spaces from workspace source plan * fix: prevent resume status from creating phantom turns * fix(web): stabilize workspace source attachment * refactor(web): extract workspace source store contract * fix: avoid phantom turns on idle agent resume * fix: address backend static analysis findings * fix: preserve agentctl readiness status value * fix: preserve resume messages without active turns * fix: resume agents from promoted workspace root * chore: merge origin/main into feature/add-new-repo-folder-d97 * feat(web): explain workspace source consequences * test(websocket): count session activity subscription
58 lines
1.8 KiB
Go
58 lines
1.8 KiB
Go
package worktree
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestCreateOwnedDirectoryLinkCreatesLiveLinkInsideOwnedRoot(t *testing.T) {
|
|
root := filepath.Join(t.TempDir(), "tasks", "task-1")
|
|
target := filepath.Join(t.TempDir(), "source")
|
|
if err := os.MkdirAll(target, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(target, "live.txt"), []byte("one"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
link, err := CreateOwnedDirectoryLink(root, "source", target)
|
|
if err != nil {
|
|
t.Fatalf("CreateOwnedDirectoryLink: %v", err)
|
|
}
|
|
if got, err := os.ReadFile(filepath.Join(link, "live.txt")); err != nil || string(got) != "one" {
|
|
t.Fatalf("read through link = %q, %v", got, err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(target, "live.txt"), []byte("two"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got, err := os.ReadFile(filepath.Join(link, "live.txt")); err != nil || string(got) != "two" {
|
|
t.Fatalf("link is not live: %q, %v", got, err)
|
|
}
|
|
}
|
|
|
|
func TestCreateOwnedDirectoryLinkRejectsCollision(t *testing.T) {
|
|
root := filepath.Join(t.TempDir(), "tasks", "task-1")
|
|
target := t.TempDir()
|
|
if err := os.MkdirAll(root, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.Mkdir(filepath.Join(root, "source"), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := CreateOwnedDirectoryLink(root, "source", target); err == nil {
|
|
t.Fatal("CreateOwnedDirectoryLink succeeded for collision")
|
|
}
|
|
}
|
|
|
|
func TestCreateOwnedDirectoryLinkRejectsSymlinkedControlAncestor(t *testing.T) {
|
|
realBase := t.TempDir()
|
|
linkBase := filepath.Join(t.TempDir(), "tasks")
|
|
if err := os.Symlink(realBase, linkBase); err != nil {
|
|
t.Skipf("symlink unsupported: %v", err)
|
|
}
|
|
if _, err := CreateOwnedDirectoryLink(filepath.Join(linkBase, "task-1"), "source", t.TempDir()); err == nil {
|
|
t.Fatal("CreateOwnedDirectoryLink accepted symlinked control ancestor")
|
|
}
|
|
}
|