* fix: prefer bootstrap for missing database recovery Executed-By: beads/crew/emma * fix: align doctor recovery guidance with bootstrap Executed-By: beads/crew/emma * fix: let bootstrap recover missing server databases Executed-By: beads/crew/emma * fix: bootstrap missing server databases safely Executed-By: beads/crew/emma * fix: fail closed on bootstrap server probe errors Executed-By: beads/crew/emma * fix: honor runtime server config in bootstrap Executed-By: beads/crew/emma * docs: soften bootstrap-first recovery wording Executed-By: beads/crew/emma * fix: report resolved bootstrap server port Executed-By: beads/crew/emma * fix: repair test failures from build tag mismatch and mode detection Three issues causing CI failures on macOS and Ubuntu: 1. detectBootstrapAction used isEmbeddedMode() (global state) to choose the database path, but tests set cfg.DoltMode without updating the global serverMode flag. Switch to cfg.GetDoltMode() so the detection logic respects the config object passed by the caller. 2. TestDetectBootstrapAction_NoneWhenDatabaseExists created a "dolt" directory but default (embedded) config looks for "embeddeddolt". Fix the test to create the correct directory. 3. embeddeddolt/slots.go and new_methods_test.go used //go:build embeddeddolt tag while all other files in the package use cgo, causing interface satisfaction failures. Also fix undefined isEmbeddedDolt reference (should be isEmbeddedMode()). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Executed-By: beads/crew/emma --------- Co-authored-by: mayor <thalia.geraghty@fiserv.com> Co-authored-by: beads/crew/emma <steve.yegge@gmail.com>
273 lines
6.9 KiB
Go
273 lines
6.9 KiB
Go
//go:build cgo
|
|
|
|
package embeddeddolt_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
func TestReopenIssue(t *testing.T) {
|
|
skipUnlessEmbeddedDolt(t)
|
|
|
|
t.Run("close_then_reopen", func(t *testing.T) {
|
|
te := newTestEnv(t, "ro")
|
|
ctx := t.Context()
|
|
|
|
issue := &types.Issue{
|
|
ID: "ro-1",
|
|
Title: "Reopen test",
|
|
Status: types.StatusOpen,
|
|
Priority: 2,
|
|
IssueType: types.TypeTask,
|
|
}
|
|
if err := te.store.CreateIssue(ctx, issue, "tester"); err != nil {
|
|
t.Fatalf("CreateIssue: %v", err)
|
|
}
|
|
|
|
// Close it.
|
|
if err := te.store.CloseIssue(ctx, "ro-1", "done", "tester", ""); err != nil {
|
|
t.Fatalf("CloseIssue: %v", err)
|
|
}
|
|
|
|
// Verify it is closed.
|
|
got, err := te.store.GetIssue(ctx, "ro-1")
|
|
if err != nil {
|
|
t.Fatalf("GetIssue after close: %v", err)
|
|
}
|
|
if got.Status != types.StatusClosed {
|
|
t.Fatalf("expected status closed, got %q", got.Status)
|
|
}
|
|
if got.ClosedAt == nil {
|
|
t.Fatal("expected ClosedAt to be set after close")
|
|
}
|
|
|
|
// Reopen it.
|
|
if err := te.store.ReopenIssue(ctx, "ro-1", "not actually done", "tester"); err != nil {
|
|
t.Fatalf("ReopenIssue: %v", err)
|
|
}
|
|
|
|
got, err = te.store.GetIssue(ctx, "ro-1")
|
|
if err != nil {
|
|
t.Fatalf("GetIssue after reopen: %v", err)
|
|
}
|
|
if got.Status != types.StatusOpen {
|
|
t.Errorf("expected status open after reopen, got %q", got.Status)
|
|
}
|
|
if got.ClosedAt != nil {
|
|
t.Errorf("expected ClosedAt nil after reopen, got %v", got.ClosedAt)
|
|
}
|
|
})
|
|
}
|
|
|
|
func TestUpdateIssueType(t *testing.T) {
|
|
skipUnlessEmbeddedDolt(t)
|
|
|
|
t.Run("task_to_feature", func(t *testing.T) {
|
|
te := newTestEnv(t, "ut")
|
|
ctx := t.Context()
|
|
|
|
issue := &types.Issue{
|
|
ID: "ut-1",
|
|
Title: "Type change test",
|
|
Status: types.StatusOpen,
|
|
Priority: 2,
|
|
IssueType: types.TypeTask,
|
|
}
|
|
if err := te.store.CreateIssue(ctx, issue, "tester"); err != nil {
|
|
t.Fatalf("CreateIssue: %v", err)
|
|
}
|
|
|
|
if err := te.store.UpdateIssueType(ctx, "ut-1", string(types.TypeFeature), "tester"); err != nil {
|
|
t.Fatalf("UpdateIssueType: %v", err)
|
|
}
|
|
|
|
got, err := te.store.GetIssue(ctx, "ut-1")
|
|
if err != nil {
|
|
t.Fatalf("GetIssue: %v", err)
|
|
}
|
|
if got.IssueType != types.TypeFeature {
|
|
t.Errorf("IssueType: got %q, want %q", got.IssueType, types.TypeFeature)
|
|
}
|
|
})
|
|
}
|
|
|
|
func TestListWisps(t *testing.T) {
|
|
skipUnlessEmbeddedDolt(t)
|
|
|
|
t.Run("only_ephemeral_returned", func(t *testing.T) {
|
|
te := newTestEnv(t, "lw")
|
|
ctx := t.Context()
|
|
|
|
// Create a regular (non-ephemeral) issue.
|
|
regular := &types.Issue{
|
|
ID: "lw-regular",
|
|
Title: "Regular issue",
|
|
Status: types.StatusOpen,
|
|
Priority: 2,
|
|
IssueType: types.TypeTask,
|
|
}
|
|
if err := te.store.CreateIssue(ctx, regular, "tester"); err != nil {
|
|
t.Fatalf("CreateIssue (regular): %v", err)
|
|
}
|
|
|
|
// Create an ephemeral issue (wisp).
|
|
wisp := &types.Issue{
|
|
ID: "lw-wisp-1",
|
|
Title: "Ephemeral wisp",
|
|
Status: types.StatusOpen,
|
|
Priority: 2,
|
|
IssueType: types.TypeTask,
|
|
Ephemeral: true,
|
|
}
|
|
if err := te.store.CreateIssue(ctx, wisp, "tester"); err != nil {
|
|
t.Fatalf("CreateIssue (wisp): %v", err)
|
|
}
|
|
|
|
// ListWisps with empty filter should return only the ephemeral issue.
|
|
wisps, err := te.store.ListWisps(ctx, types.WispFilter{})
|
|
if err != nil {
|
|
t.Fatalf("ListWisps: %v", err)
|
|
}
|
|
|
|
// Verify only the ephemeral one is in results.
|
|
found := false
|
|
for _, w := range wisps {
|
|
if w.ID == "lw-regular" {
|
|
t.Errorf("ListWisps returned non-ephemeral issue %q", w.ID)
|
|
}
|
|
if w.ID == "lw-wisp-1" {
|
|
found = true
|
|
}
|
|
}
|
|
if !found {
|
|
t.Errorf("ListWisps did not return ephemeral issue lw-wisp-1; got %d results", len(wisps))
|
|
}
|
|
})
|
|
|
|
t.Run("empty_when_no_wisps", func(t *testing.T) {
|
|
te := newTestEnv(t, "le")
|
|
ctx := t.Context()
|
|
|
|
// Create only a regular issue.
|
|
regular := &types.Issue{
|
|
ID: "le-1",
|
|
Title: "Regular only",
|
|
Status: types.StatusOpen,
|
|
Priority: 2,
|
|
IssueType: types.TypeTask,
|
|
}
|
|
if err := te.store.CreateIssue(ctx, regular, "tester"); err != nil {
|
|
t.Fatalf("CreateIssue: %v", err)
|
|
}
|
|
|
|
wisps, err := te.store.ListWisps(ctx, types.WispFilter{})
|
|
if err != nil {
|
|
t.Fatalf("ListWisps: %v", err)
|
|
}
|
|
if len(wisps) != 0 {
|
|
t.Errorf("expected 0 wisps, got %d", len(wisps))
|
|
}
|
|
})
|
|
}
|
|
|
|
func TestGetReadyWorkMoleculeFilter(t *testing.T) {
|
|
skipUnlessEmbeddedDolt(t)
|
|
|
|
t.Run("filter_by_molecule_id", func(t *testing.T) {
|
|
te := newTestEnv(t, "gm")
|
|
ctx := t.Context()
|
|
|
|
// Create a molecule (parent).
|
|
mol := &types.Issue{
|
|
ID: "gm-mol-1",
|
|
Title: "Test molecule",
|
|
Status: types.StatusOpen,
|
|
Priority: 2,
|
|
IssueType: types.TypeMolecule,
|
|
}
|
|
if err := te.store.CreateIssue(ctx, mol, "tester"); err != nil {
|
|
t.Fatalf("CreateIssue (molecule): %v", err)
|
|
}
|
|
|
|
// Create child issues of this molecule.
|
|
child1 := &types.Issue{
|
|
ID: "gm-child-1",
|
|
Title: "Child 1",
|
|
Status: types.StatusOpen,
|
|
Priority: 2,
|
|
IssueType: types.TypeTask,
|
|
}
|
|
child2 := &types.Issue{
|
|
ID: "gm-child-2",
|
|
Title: "Child 2",
|
|
Status: types.StatusOpen,
|
|
Priority: 2,
|
|
IssueType: types.TypeTask,
|
|
}
|
|
if err := te.store.CreateIssue(ctx, child1, "tester"); err != nil {
|
|
t.Fatalf("CreateIssue (child1): %v", err)
|
|
}
|
|
if err := te.store.CreateIssue(ctx, child2, "tester"); err != nil {
|
|
t.Fatalf("CreateIssue (child2): %v", err)
|
|
}
|
|
|
|
// Create an unrelated issue (not a child of the molecule).
|
|
unrelated := &types.Issue{
|
|
ID: "gm-other",
|
|
Title: "Unrelated",
|
|
Status: types.StatusOpen,
|
|
Priority: 2,
|
|
IssueType: types.TypeTask,
|
|
}
|
|
if err := te.store.CreateIssue(ctx, unrelated, "tester"); err != nil {
|
|
t.Fatalf("CreateIssue (unrelated): %v", err)
|
|
}
|
|
|
|
// Add parent-child dependencies: molecule -> child1, molecule -> child2.
|
|
dep1 := &types.Dependency{
|
|
IssueID: "gm-child-1",
|
|
DependsOnID: "gm-mol-1",
|
|
Type: types.DepParentChild,
|
|
}
|
|
dep2 := &types.Dependency{
|
|
IssueID: "gm-child-2",
|
|
DependsOnID: "gm-mol-1",
|
|
Type: types.DepParentChild,
|
|
}
|
|
if err := te.store.AddDependency(ctx, dep1, "tester"); err != nil {
|
|
t.Fatalf("AddDependency (child1): %v", err)
|
|
}
|
|
if err := te.store.AddDependency(ctx, dep2, "tester"); err != nil {
|
|
t.Fatalf("AddDependency (child2): %v", err)
|
|
}
|
|
|
|
// GetReadyWork filtered by MoleculeID should return only children.
|
|
filter := types.WorkFilter{
|
|
MoleculeID: "gm-mol-1",
|
|
}
|
|
ready, err := te.store.GetReadyWork(ctx, filter)
|
|
if err != nil {
|
|
t.Fatalf("GetReadyWork: %v", err)
|
|
}
|
|
|
|
ids := make(map[string]bool)
|
|
for _, r := range ready {
|
|
ids[r.ID] = true
|
|
}
|
|
|
|
if !ids["gm-child-1"] {
|
|
t.Errorf("expected gm-child-1 in ready work, got %v", ids)
|
|
}
|
|
if !ids["gm-child-2"] {
|
|
t.Errorf("expected gm-child-2 in ready work, got %v", ids)
|
|
}
|
|
if ids["gm-other"] {
|
|
t.Errorf("unrelated issue gm-other should not appear in molecule-filtered ready work")
|
|
}
|
|
if ids["gm-mol-1"] {
|
|
t.Errorf("molecule gm-mol-1 itself should not appear as ready work child")
|
|
}
|
|
})
|
|
}
|