(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func TestManagerRegister(t *testing.T) { |
| 52 | tmpDir := t.TempDir() |
| 53 | prdPath := createTestPRDWithName(t, tmpDir, "test-prd") |
| 54 | |
| 55 | m := NewManager(10, testProvider) |
| 56 | |
| 57 | // Register a new PRD |
| 58 | err := m.Register("test-prd", prdPath) |
| 59 | if err != nil { |
| 60 | t.Fatalf("unexpected error: %v", err) |
| 61 | } |
| 62 | |
| 63 | // Verify it was registered |
| 64 | instance := m.GetInstance("test-prd") |
| 65 | if instance == nil { |
| 66 | t.Fatal("expected instance to be registered") |
| 67 | } |
| 68 | if instance.Name != "test-prd" { |
| 69 | t.Errorf("expected name 'test-prd', got '%s'", instance.Name) |
| 70 | } |
| 71 | if instance.State != LoopStateReady { |
| 72 | t.Errorf("expected state Ready, got %v", instance.State) |
| 73 | } |
| 74 | |
| 75 | // Try to register again - should fail |
| 76 | err = m.Register("test-prd", prdPath) |
| 77 | if err == nil { |
| 78 | t.Error("expected error when registering duplicate PRD") |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | func TestManagerUnregister(t *testing.T) { |
| 83 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected