From 59bc518eee4026fa072c163149389b05428b5398 Mon Sep 17 00:00:00 2001 From: Claudomator Agent Date: Sat, 14 Mar 2026 16:02:28 +0000 Subject: 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 --- internal/storage/db_test.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'internal/storage/db_test.go') 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) + } +} + -- cgit v1.2.3