MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / TestWorktreeCreateMatchesPythonLifecycle

Function TestWorktreeCreateMatchesPythonLifecycle

test/agent_test.go:1056–1092  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1054 t.Skip("git not installed")
1055 }
1056 repo := t.TempDir()
1057 runGit(t, repo, "init")
1058 runGit(t, repo, "config", "user.email", "test@example.com")
1059 runGit(t, repo, "config", "user.name", "Test User")
1060 if err := os.WriteFile(filepath.Join(repo, "README.md"), []byte("hello\n"), 0o644); err != nil {
1061 t.Fatal(err)
1062 }
1063 runGit(t, repo, "add", "README.md")
1064 runGit(t, repo, "commit", "-m", "initial")
1065
1066 result, err := agent.CreateWorktree(context.Background(), repo, "HEAD", "Explore", ".Lumina/worktrees")
1067 if err != nil {
1068 t.Fatal(err)
1069 }
1070 if result.RepoRoot != repo || result.BaseRef != "HEAD" {
1071 t.Fatalf("unexpected worktree metadata: %#v", result)
1072 }
1073 if result.WorktreePath == "" || !strings.Contains(filepath.ToSlash(result.WorktreePath), "/.Lumina/worktrees/Explore-") {
1074 t.Fatalf("unexpected worktree path: %#v", result)
1075 }
1076 if result.BranchName != "" {
1077 t.Fatalf("Python worktree creation does not create a branch, got %q", result.BranchName)
1078 }
1079 if _, err := os.Stat(filepath.Join(result.WorktreePath, "README.md")); err != nil {
1080 t.Fatalf("expected worktree checkout: %v", err)
1081 }
1082 if err := agent.RemoveWorktree(context.Background(), result.WorktreePath); err != nil {
1083 t.Fatal(err)
1084 }
1085 if _, err := os.Stat(result.WorktreePath); !os.IsNotExist(err) {
1086 t.Fatalf("expected worktree removed, stat err=%v", err)
1087 }
1088}
1089
1090func TestWorktreeCreateGracefullyDegradesOutsideGit(t *testing.T) {
1091 dir := t.TempDir()
1092 result, err := agent.CreateWorktree(context.Background(), dir, "HEAD", "Explore", ".Lumina/worktrees")
1093 if err != nil {
1094 t.Fatal(err)
1095 }

Callers

nothing calls this directly

Calls 3

CreateWorktreeFunction · 0.92
RemoveWorktreeFunction · 0.92
runGitFunction · 0.70

Tested by

no test coverage detected