(t *testing.T)
| 375 | } |
| 376 | |
| 377 | func TestManagerRegisterWithWorktree(t *testing.T) { |
| 378 | tmpDir := t.TempDir() |
| 379 | prdPath := createTestPRDWithName(t, tmpDir, "test-prd") |
| 380 | |
| 381 | m := NewManager(10, testProvider) |
| 382 | |
| 383 | err := m.RegisterWithWorktree("test-prd", prdPath, "/tmp/worktree/test-prd", "chief/test-prd") |
| 384 | if err != nil { |
| 385 | t.Fatalf("unexpected error: %v", err) |
| 386 | } |
| 387 | |
| 388 | instance := m.GetInstance("test-prd") |
| 389 | if instance == nil { |
| 390 | t.Fatal("expected instance to be registered") |
| 391 | } |
| 392 | if instance.Name != "test-prd" { |
| 393 | t.Errorf("expected name 'test-prd', got '%s'", instance.Name) |
| 394 | } |
| 395 | if instance.WorktreeDir != "/tmp/worktree/test-prd" { |
| 396 | t.Errorf("expected WorktreeDir '/tmp/worktree/test-prd', got '%s'", instance.WorktreeDir) |
| 397 | } |
| 398 | if instance.Branch != "chief/test-prd" { |
| 399 | t.Errorf("expected Branch 'chief/test-prd', got '%s'", instance.Branch) |
| 400 | } |
| 401 | if instance.State != LoopStateReady { |
| 402 | t.Errorf("expected state Ready, got %v", instance.State) |
| 403 | } |
| 404 | |
| 405 | // Duplicate registration should fail |
| 406 | err = m.RegisterWithWorktree("test-prd", prdPath, "/tmp/worktree/test-prd", "chief/test-prd") |
| 407 | if err == nil { |
| 408 | t.Error("expected error when registering duplicate PRD") |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | func TestManagerRegisterWithWorktreeFieldsInGetAllInstances(t *testing.T) { |
| 413 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected