diff --git a/cmd/bd/show_watch_test.go b/cmd/bd/show_watch_test.go index cac36f17e..197f0698d 100644 --- a/cmd/bd/show_watch_test.go +++ b/cmd/bd/show_watch_test.go @@ -124,13 +124,20 @@ func TestWatchIssueDetectsFieldUpdate(t *testing.T) { dbPath := filepath.Join(tmpDir, ".beads", "test.db") s := newTestStore(t, dbPath) + // Seed updated_at an hour in the past so the title update's fresh (now) + // timestamp is unambiguously newer. A title change is not itself reflected in + // singleIssueSnapshot, which compares updated_at at 1-second granularity — so a + // same-second create+update (the common case on a fast machine) would tie and + // spuriously fail. CreateIssue honors a non-zero UpdatedAt (see issueops + // create.go), making the gap deterministic. + seeded := time.Now().Add(-time.Hour) issue := &types.Issue{ ID: generateUniqueTestID(t, "test", 0), Title: "original title", Status: types.StatusOpen, IssueType: types.TypeTask, - CreatedAt: time.Now(), - UpdatedAt: time.Now(), + CreatedAt: seeded, + UpdatedAt: seeded, } if err := s.CreateIssue(ctx, issue, "test-actor"); err != nil { t.Fatalf("CreateIssue: %v", err) @@ -142,7 +149,7 @@ func TestWatchIssueDetectsFieldUpdate(t *testing.T) { } snapBefore := singleIssueSnapshot(got) - // Update title (which bumps UpdatedAt) + // Update title (which bumps UpdatedAt to now, an hour after the seed) if err := s.UpdateIssue(ctx, issue.ID, map[string]interface{}{"title": "updated title"}, "test-actor"); err != nil { t.Fatalf("UpdateIssue: %v", err) }