refactor: Remove in-memory swarms map, make Manager stateless
The swarm Manager was maintaining an in-memory map of swarms that was never persisted and duplicated state from beads. This caused stale state after restarts and confusion about source of truth. Changes: - Remove swarms map from Manager (now stateless) - Add LoadSwarm() that queries beads for swarm state - Refactor all methods to use LoadSwarm() instead of in-memory lookup - Discover workers from assigned tasks in beads - Remove obsolete unit tests that tested in-memory behavior - Keep type/state tests that do not need beads The E2E test (gt-kc7yj.4) now covers the beads integration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,39 +6,6 @@ import (
|
||||
"github.com/steveyegge/gastown/internal/rig"
|
||||
)
|
||||
|
||||
func TestGetIntegrationBranch(t *testing.T) {
|
||||
r := &rig.Rig{
|
||||
Name: "test-rig",
|
||||
Path: "/tmp/test-rig",
|
||||
}
|
||||
m := NewManager(r)
|
||||
|
||||
swarm, _ := m.Create("epic-1", []string{"Toast"}, "main")
|
||||
|
||||
branch, err := m.GetIntegrationBranch(swarm.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("GetIntegrationBranch failed: %v", err)
|
||||
}
|
||||
|
||||
expected := "swarm/epic-1"
|
||||
if branch != expected {
|
||||
t.Errorf("branch = %q, want %q", branch, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetIntegrationBranchNotFound(t *testing.T) {
|
||||
r := &rig.Rig{
|
||||
Name: "test-rig",
|
||||
Path: "/tmp/test-rig",
|
||||
}
|
||||
m := NewManager(r)
|
||||
|
||||
_, err := m.GetIntegrationBranch("nonexistent")
|
||||
if err != ErrSwarmNotFound {
|
||||
t.Errorf("GetIntegrationBranch = %v, want ErrSwarmNotFound", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetWorkerBranch(t *testing.T) {
|
||||
r := &rig.Rig{
|
||||
Name: "test-rig",
|
||||
@@ -53,54 +20,5 @@ func TestGetWorkerBranch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateIntegrationBranchSwarmNotFound(t *testing.T) {
|
||||
r := &rig.Rig{
|
||||
Name: "test-rig",
|
||||
Path: "/tmp/test-rig",
|
||||
}
|
||||
m := NewManager(r)
|
||||
|
||||
err := m.CreateIntegrationBranch("nonexistent")
|
||||
if err != ErrSwarmNotFound {
|
||||
t.Errorf("CreateIntegrationBranch = %v, want ErrSwarmNotFound", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeToIntegrationSwarmNotFound(t *testing.T) {
|
||||
r := &rig.Rig{
|
||||
Name: "test-rig",
|
||||
Path: "/tmp/test-rig",
|
||||
}
|
||||
m := NewManager(r)
|
||||
|
||||
err := m.MergeToIntegration("nonexistent", "branch")
|
||||
if err != ErrSwarmNotFound {
|
||||
t.Errorf("MergeToIntegration = %v, want ErrSwarmNotFound", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLandToMainSwarmNotFound(t *testing.T) {
|
||||
r := &rig.Rig{
|
||||
Name: "test-rig",
|
||||
Path: "/tmp/test-rig",
|
||||
}
|
||||
m := NewManager(r)
|
||||
|
||||
err := m.LandToMain("nonexistent")
|
||||
if err != ErrSwarmNotFound {
|
||||
t.Errorf("LandToMain = %v, want ErrSwarmNotFound", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCleanupBranchesSwarmNotFound(t *testing.T) {
|
||||
r := &rig.Rig{
|
||||
Name: "test-rig",
|
||||
Path: "/tmp/test-rig",
|
||||
}
|
||||
m := NewManager(r)
|
||||
|
||||
err := m.CleanupBranches("nonexistent")
|
||||
if err != ErrSwarmNotFound {
|
||||
t.Errorf("CleanupBranches = %v, want ErrSwarmNotFound", err)
|
||||
}
|
||||
}
|
||||
// Note: Integration tests that require git operations and beads
|
||||
// are covered by the E2E test (gt-kc7yj.4).
|
||||
|
||||
Reference in New Issue
Block a user