Adds 11 new test files exercising every bd mol/wisp/pour subcommand against a real proxied-server (dolt sql-server via testcontainers), following the existing t.Parallel() + newSharedProxiedProject pattern from ready_wisp_proxied_integration_test.go. Covers show, current, progress, last-activity, stale, ready --gated, distill, pour, bond, squash, burn, and wisp create/list/gc — 47 subtests total. Running these against a live container surfaced and fixed two real bugs in the proxied-server mol port (cmd/bd/mol_port.go): - uowMolReader.GetIssue/GetIssuesByIDs never hydrated Labels (the domain layer's IssueUseCase.GetIssue doesn't join labels the way storage.DoltStorage.GetIssue does), which broke every isProto/ isProtoIssue check downstream (pour, wisp create, bond). - uowMolWriter.AddDependency routed to the wisp_dependencies table whenever either end of a dependency was a wisp; it must route based on dep.IssueID alone (the depender), since the target column (depends_on_wisp_id vs depends_on_issue_id) is already resolved dynamically by the underlying repo insert. The old routing caused an FK violation whenever a persistent digest issue was linked to an ephemeral wisp root during squash. Also fixes a real nil-pointer panic in wisp_proxied_server.go's runWispPurgeClosedProxiedServer: it closed the UnitOfWork's connection before a loop that still called IsInfraTypeCtx through it. Testing also surfaced two pre-existing (not introduced here) bugs shared identically by both backends, confirmed by manually running the embedded CLI: `bd mol stale --all` can never surface childless epics (GetEpicsEligibleForClosure skips zero-child epics before --all is consulted), and `bd mol bond` can never produce a "compound_proto" result via any real CLI invocation (its dispatch checks issue.IsTemplate, which is only set on never-persisted formula-cooked subgraphs, while bondProtoProto assumes its operands are already-persisted DB issues). The new tests document these as parity guards rather than silently skipping them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
117 lines
3.7 KiB
Go
117 lines
3.7 KiB
Go
//go:build cgo
|
|
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestProxiedServerMolBurn(t *testing.T) {
|
|
requireSharedProxiedServer(t)
|
|
t.Parallel()
|
|
bd := buildEmbeddedBD(t)
|
|
|
|
t.Run("burns_single_wisp_molecule", func(t *testing.T) {
|
|
t.Parallel()
|
|
p := newSharedProxiedProject(t, bd, "mbu")
|
|
root := bdProxiedCreate(t, bd, p.dir, "Wisp burn root", "--type", "epic", "--ephemeral")
|
|
child := bdProxiedCreate(t, bd, p.dir, "Wisp burn child", "--type", "task", "--parent", root.ID, "--ephemeral")
|
|
|
|
out, err := bdProxiedRun(t, bd, p.dir, "mol", "burn", root.ID, "--force", "--json")
|
|
if err != nil {
|
|
t.Fatalf("bd mol burn --force --json: %v\n%s", err, out)
|
|
}
|
|
|
|
db := openProxiedDB(t, p)
|
|
for _, id := range []string{root.ID, child.ID} {
|
|
var count int
|
|
if err := db.QueryRow("SELECT COUNT(*) FROM wisps WHERE id = ?", id).Scan(&count); err != nil {
|
|
t.Fatalf("query wisps for %s: %v", id, err)
|
|
}
|
|
if count != 0 {
|
|
t.Errorf("expected %s to be deleted from wisps table", id)
|
|
}
|
|
}
|
|
})
|
|
|
|
t.Run("burns_single_persistent_molecule", func(t *testing.T) {
|
|
t.Parallel()
|
|
p := newSharedProxiedProject(t, bd, "mbup")
|
|
root := bdProxiedCreate(t, bd, p.dir, "Persistent burn root", "--type", "epic")
|
|
child := bdProxiedCreate(t, bd, p.dir, "Persistent burn child", "--type", "task", "--parent", root.ID)
|
|
|
|
out, err := bdProxiedRun(t, bd, p.dir, "mol", "burn", root.ID, "--force", "--json")
|
|
if err != nil {
|
|
t.Fatalf("bd mol burn --force --json: %v\n%s", err, out)
|
|
}
|
|
|
|
db := openProxiedDB(t, p)
|
|
for _, id := range []string{root.ID, child.ID} {
|
|
var count int
|
|
if err := db.QueryRow("SELECT COUNT(*) FROM issues WHERE id = ?", id).Scan(&count); err != nil {
|
|
t.Fatalf("query issues for %s: %v", id, err)
|
|
}
|
|
if count != 0 {
|
|
t.Errorf("expected %s to be deleted from issues table", id)
|
|
}
|
|
}
|
|
})
|
|
|
|
t.Run("burns_multiple_mixed_wisp_and_persistent", func(t *testing.T) {
|
|
t.Parallel()
|
|
p := newSharedProxiedProject(t, bd, "mbum")
|
|
wispRoot := bdProxiedCreate(t, bd, p.dir, "Mixed wisp root", "--type", "epic", "--ephemeral")
|
|
persistentRoot := bdProxiedCreate(t, bd, p.dir, "Mixed persistent root", "--type", "epic")
|
|
|
|
out, err := bdProxiedRun(t, bd, p.dir, "mol", "burn", wispRoot.ID, persistentRoot.ID, "--force", "--json")
|
|
if err != nil {
|
|
t.Fatalf("bd mol burn --force --json (batch): %v\n%s", err, out)
|
|
}
|
|
var got struct {
|
|
TotalDeleted int `json:"total_deleted"`
|
|
}
|
|
if err := json.Unmarshal(out, &got); err != nil {
|
|
t.Fatalf("unmarshal: %v\n%s", err, out)
|
|
}
|
|
if got.TotalDeleted != 2 {
|
|
t.Errorf("total_deleted = %d, want 2", got.TotalDeleted)
|
|
}
|
|
|
|
db := openProxiedDB(t, p)
|
|
var wispCount int
|
|
if err := db.QueryRow("SELECT COUNT(*) FROM wisps WHERE id = ?", wispRoot.ID).Scan(&wispCount); err != nil {
|
|
t.Fatalf("query wisps: %v", err)
|
|
}
|
|
if wispCount != 0 {
|
|
t.Errorf("expected wisp root %s deleted", wispRoot.ID)
|
|
}
|
|
var issueCount int
|
|
if err := db.QueryRow("SELECT COUNT(*) FROM issues WHERE id = ?", persistentRoot.ID).Scan(&issueCount); err != nil {
|
|
t.Fatalf("query issues: %v", err)
|
|
}
|
|
if issueCount != 0 {
|
|
t.Errorf("expected persistent root %s deleted", persistentRoot.ID)
|
|
}
|
|
})
|
|
|
|
t.Run("dry_run_deletes_nothing", func(t *testing.T) {
|
|
t.Parallel()
|
|
p := newSharedProxiedProject(t, bd, "mbud")
|
|
root := bdProxiedCreate(t, bd, p.dir, "Dry burn root", "--type", "epic")
|
|
|
|
stdout, _, err := bdProxiedRunBuffers(t, bd, p.dir, "mol", "burn", root.ID, "--dry-run")
|
|
if err != nil {
|
|
t.Fatalf("bd mol burn --dry-run: %v\n%s", err, stdout)
|
|
}
|
|
if !strings.Contains(stdout, "Dry run") {
|
|
t.Errorf("expected dry-run preview, got: %s", stdout)
|
|
}
|
|
|
|
spawned := bdProxiedShow(t, bd, p.dir, root.ID)
|
|
if spawned.ID != root.ID {
|
|
t.Errorf("expected root %s to survive --dry-run", root.ID)
|
|
}
|
|
})
|
|
}
|