summaryrefslogtreecommitdiff
path: root/internal/storage/db_test.go
diff options
context:
space:
mode:
authorClaudomator Agent <agent@claudomator.local>2026-07-09 03:02:18 +0000
committerClaudomator Agent <agent@claudomator.local>2026-07-09 03:02:18 +0000
commit5ea8f50b0c43a23af6e65bce1fe057a355cb1929 (patch)
tree239b69867e5d321dab65f6eb2a58705765fe5b26 /internal/storage/db_test.go
parent647befd36bae81d478101f8dc4909432f6807fc6 (diff)
feat(task,storage): add Task.AcceptanceCriteria, mirroring story.Story's pattern
Diffstat (limited to 'internal/storage/db_test.go')
-rw-r--r--internal/storage/db_test.go65
1 files changed, 65 insertions, 0 deletions
diff --git a/internal/storage/db_test.go b/internal/storage/db_test.go
index b53234a..3adf17f 100644
--- a/internal/storage/db_test.go
+++ b/internal/storage/db_test.go
@@ -1057,6 +1057,71 @@ func TestCreateTask_Project_RoundTrip(t *testing.T) {
}
}
+func TestCreateTask_AcceptanceCriteria_RoundTrip(t *testing.T) {
+ db := testDB(t)
+ now := time.Now().UTC().Truncate(time.Second)
+
+ tk := &task.Task{
+ ID: "ac-1",
+ Name: "Task With Criteria",
+ Agent: task.AgentConfig{Type: "claude", Instructions: "do it"},
+ Priority: task.PriorityNormal,
+ Tags: []string{},
+ DependsOn: []string{},
+ AcceptanceCriteria: []string{"tests pass", "no new lint warnings"},
+ Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"},
+ State: task.StatePending,
+ CreatedAt: now,
+ UpdatedAt: now,
+ }
+ if err := db.CreateTask(tk); err != nil {
+ t.Fatalf("creating task: %v", err)
+ }
+
+ got, err := db.GetTask("ac-1")
+ if err != nil {
+ t.Fatalf("getting task: %v", err)
+ }
+ if len(got.AcceptanceCriteria) != 2 || got.AcceptanceCriteria[0] != "tests pass" || got.AcceptanceCriteria[1] != "no new lint warnings" {
+ t.Errorf("AcceptanceCriteria: want [tests pass, no new lint warnings], got %+v", got.AcceptanceCriteria)
+ }
+}
+
+// TestCreateTask_AcceptanceCriteria_DefaultsEmpty proves a task created
+// without AcceptanceCriteria round-trips as an empty (not nil) slice, the
+// same "never null" convention story.Story.AcceptanceCriteria already uses.
+func TestCreateTask_AcceptanceCriteria_DefaultsEmpty(t *testing.T) {
+ db := testDB(t)
+ now := time.Now().UTC().Truncate(time.Second)
+
+ tk := &task.Task{
+ ID: "ac-2",
+ Name: "Task Without Criteria",
+ Agent: task.AgentConfig{Type: "claude", Instructions: "do it"},
+ Priority: task.PriorityNormal,
+ Tags: []string{},
+ DependsOn: []string{},
+ Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"},
+ State: task.StatePending,
+ CreatedAt: now,
+ UpdatedAt: now,
+ }
+ if err := db.CreateTask(tk); err != nil {
+ t.Fatalf("creating task: %v", err)
+ }
+
+ got, err := db.GetTask("ac-2")
+ if err != nil {
+ t.Fatalf("getting task: %v", err)
+ }
+ if got.AcceptanceCriteria == nil {
+ t.Error("AcceptanceCriteria: want empty slice, got nil")
+ }
+ if len(got.AcceptanceCriteria) != 0 {
+ t.Errorf("AcceptanceCriteria: want empty, got %+v", got.AcceptanceCriteria)
+ }
+}
+
// ── Push subscription tests ───────────────────────────────────────────────────
func TestPushSubscription_SaveAndList(t *testing.T) {