diff options
| author | Claudomator Agent <agent@claudomator> | 2026-03-14 16:02:28 +0000 |
|---|---|---|
| committer | Claudomator Agent <agent@claudomator> | 2026-03-14 16:02:28 +0000 |
| commit | 59bc518eee4026fa072c163149389b05428b5398 (patch) | |
| tree | fbcde553161e5ac4784d70426a57434e003b1287 /internal/storage/db_test.go | |
| parent | 4029fdd82bdd657ed862c89f20eb03ff2594cde9 (diff) | |
feat: add Changestats struct and storage support
- Add task.Changestats{FilesChanged, LinesAdded, LinesRemoved}
- Add changestats_json column to executions via additive migration
- Add Changestats field to storage.Execution struct
- Add UpdateExecutionChangestats(execID, *task.Changestats) method
- Update all SELECT/INSERT/scan paths for executions
- Test: TestExecution_StoreAndRetrieveChangestats (was red, now green)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/storage/db_test.go')
| -rw-r--r-- | internal/storage/db_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/internal/storage/db_test.go b/internal/storage/db_test.go index 31be246..a16311d 100644 --- a/internal/storage/db_test.go +++ b/internal/storage/db_test.go @@ -893,3 +893,45 @@ func TestAppendTaskInteraction_NotFound(t *testing.T) { } } +func TestExecution_StoreAndRetrieveChangestats(t *testing.T) { + db := testDB(t) + now := time.Now().UTC().Truncate(time.Second) + db.CreateTask(makeTestTask("cs-task", now)) + + exec := &Execution{ + ID: "cs-exec", + TaskID: "cs-task", + StartTime: now, + Status: "COMPLETED", + } + if err := db.CreateExecution(exec); err != nil { + t.Fatalf("CreateExecution: %v", err) + } + + stats := &task.Changestats{ + FilesChanged: 5, + LinesAdded: 127, + LinesRemoved: 43, + } + if err := db.UpdateExecutionChangestats("cs-exec", stats); err != nil { + t.Fatalf("UpdateExecutionChangestats: %v", err) + } + + got, err := db.GetExecution("cs-exec") + if err != nil { + t.Fatalf("GetExecution: %v", err) + } + if got.Changestats == nil { + t.Fatal("Changestats: want non-nil, got nil") + } + if got.Changestats.FilesChanged != 5 { + t.Errorf("FilesChanged: want 5, got %d", got.Changestats.FilesChanged) + } + if got.Changestats.LinesAdded != 127 { + t.Errorf("LinesAdded: want 127, got %d", got.Changestats.LinesAdded) + } + if got.Changestats.LinesRemoved != 43 { + t.Errorf("LinesRemoved: want 43, got %d", got.Changestats.LinesRemoved) + } +} + |
