gitgram/aitimemachine/beads/cmd/bd/closed_delete_candidates_test.go
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

73 lines
2.4 KiB
Go

package main
import (
"testing"
"time"
"github.com/steveyegge/beads/internal/types"
)
func TestFilterClosedDeletionCandidatesRechecksClosedAtCutoff(t *testing.T) {
cutoff := time.Date(2026, 3, 27, 20, 1, 44, 0, time.UTC)
oldClosedAt := cutoff.Add(-time.Second)
recentClosedAt := cutoff.Add(time.Second)
candidates := []*types.Issue{
{ID: "old-closed", Status: types.StatusClosed, ClosedAt: &oldClosedAt},
{ID: "recent-closed", Status: types.StatusClosed, ClosedAt: &recentClosedAt},
{ID: "missing-closed-at", Status: types.StatusClosed},
{ID: "open-with-old-closed-at", Status: types.StatusOpen, ClosedAt: &oldClosedAt},
{ID: "pinned-old", Status: types.StatusClosed, ClosedAt: &oldClosedAt, Pinned: true},
nil,
}
filtered, stats := filterClosedDeletionCandidates(candidates, &cutoff)
if len(filtered) != 1 || filtered[0].ID != "old-closed" {
t.Fatalf("filtered IDs = %v, want only old-closed", closedDeletionCandidateIDs(filtered))
}
if stats.PinnedSkipped != 1 {
t.Fatalf("PinnedSkipped = %d, want 1", stats.PinnedSkipped)
}
if stats.RecentClosedAtSkipped != 1 {
t.Fatalf("RecentClosedAtSkipped = %d, want 1", stats.RecentClosedAtSkipped)
}
if stats.MissingClosedAtSkipped != 1 {
t.Fatalf("MissingClosedAtSkipped = %d, want 1", stats.MissingClosedAtSkipped)
}
if stats.NonClosedSkipped != 1 {
t.Fatalf("NonClosedSkipped = %d, want 1", stats.NonClosedSkipped)
}
if stats.NilSkipped != 1 {
t.Fatalf("NilSkipped = %d, want 1", stats.NilSkipped)
}
}
func TestFilterClosedDeletionCandidatesWithoutCutoffStillRequiresClosedAt(t *testing.T) {
closedAt := time.Date(2026, 4, 26, 18, 30, 18, 0, time.UTC)
candidates := []*types.Issue{
{ID: "closed", Status: types.StatusClosed, ClosedAt: &closedAt},
{ID: "closed-missing-time", Status: types.StatusClosed},
}
filtered, stats := filterClosedDeletionCandidates(candidates, nil)
if len(filtered) != 1 || filtered[0].ID != "closed" {
t.Fatalf("filtered IDs = %v, want only closed", closedDeletionCandidateIDs(filtered))
}
if stats.MissingClosedAtSkipped != 1 {
t.Fatalf("MissingClosedAtSkipped = %d, want 1", stats.MissingClosedAtSkipped)
}
if stats.RecentClosedAtSkipped != 0 {
t.Fatalf("RecentClosedAtSkipped = %d, want 0 without cutoff", stats.RecentClosedAtSkipped)
}
}
func closedDeletionCandidateIDs(issues []*types.Issue) []string {
ids := make([]string, len(issues))
for i, issue := range issues {
ids[i] = issue.ID
}
return ids
}