test(watch): deterministically seed updated_at in TestWatchIssueDetectsFieldUpdate (#4683)
singleIssueSnapshot compares updated_at at 1-second granularity, and a title change is not otherwise reflected in the snapshot. The test created and updated the issue back-to-back, so on a fast machine both landed in the same wall-clock second, updated_at tied, and the snapshot compared equal — a spurious failure. Seed the created issue's updated_at an hour in the past (CreateIssue honors a non-zero UpdatedAt) so the title update's fresh timestamp is unambiguously newer. No production change; the watch snapshot behavior is unchanged. Co-authored-by: Test User <test@test.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fb527d034a
commit
65b0d7ea53
1 changed files with 10 additions and 3 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue