summaryrefslogtreecommitdiff
path: root/internal/storage/db_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/storage/db_test.go')
-rw-r--r--internal/storage/db_test.go42
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)
+ }
+}
+