From 83d750c4eda658fda693c1be492a674322b058d2 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Sat, 7 Mar 2026 23:50:26 +0000 Subject: test(storage): update db_test.go to use AgentConfig --- internal/storage/db_test.go | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'internal/storage') diff --git a/internal/storage/db_test.go b/internal/storage/db_test.go index fcdc529..4c3f011 100644 --- a/internal/storage/db_test.go +++ b/internal/storage/db_test.go @@ -37,7 +37,8 @@ func TestCreateTask_AndGetTask(t *testing.T) { ID: "task-1", Name: "Test Task", Description: "A test", - Claude: task.ClaudeConfig{ + Agent: task.AgentConfig{ + Type: "claude", Model: "sonnet", Instructions: "do it", WorkingDir: "/tmp", @@ -64,11 +65,11 @@ func TestCreateTask_AndGetTask(t *testing.T) { if got.Name != "Test Task" { t.Errorf("name: want 'Test Task', got %q", got.Name) } - if got.Claude.Model != "sonnet" { - t.Errorf("model: want 'sonnet', got %q", got.Claude.Model) + if got.Agent.Model != "sonnet" { + t.Errorf("model: want 'sonnet', got %q", got.Agent.Model) } - if got.Claude.MaxBudgetUSD != 2.5 { - t.Errorf("budget: want 2.5, got %f", got.Claude.MaxBudgetUSD) + if got.Agent.MaxBudgetUSD != 2.5 { + t.Errorf("budget: want 2.5, got %f", got.Agent.MaxBudgetUSD) } if got.Priority != task.PriorityHigh { t.Errorf("priority: want 'high', got %q", got.Priority) @@ -93,7 +94,7 @@ func TestUpdateTaskState(t *testing.T) { tk := &task.Task{ ID: "task-2", Name: "Stateful", - Claude: task.ClaudeConfig{Instructions: "test"}, + Agent: task.AgentConfig{Type: "claude", Instructions: "test"}, Priority: task.PriorityNormal, Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"}, Tags: []string{}, @@ -130,7 +131,7 @@ func TestListTasks_FilterByState(t *testing.T) { for i, state := range []task.State{task.StatePending, task.StatePending, task.StateRunning} { tk := &task.Task{ ID: fmt.Sprintf("t-%d", i), Name: fmt.Sprintf("Task %d", i), - Claude: task.ClaudeConfig{Instructions: "x"}, Priority: task.PriorityNormal, + Agent: task.AgentConfig{Type: "claude", Instructions: "x"}, Priority: task.PriorityNormal, Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"}, Tags: []string{}, DependsOn: []string{}, State: state, CreatedAt: now, UpdatedAt: now, @@ -163,7 +164,7 @@ func TestListTasks_WithLimit(t *testing.T) { for i := 0; i < 5; i++ { tk := &task.Task{ ID: fmt.Sprintf("lt-%d", i), Name: fmt.Sprintf("T%d", i), - Claude: task.ClaudeConfig{Instructions: "x"}, Priority: task.PriorityNormal, + Agent: task.AgentConfig{Type: "claude", Instructions: "x"}, Priority: task.PriorityNormal, Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"}, Tags: []string{}, DependsOn: []string{}, State: task.StatePending, CreatedAt: now.Add(time.Duration(i) * time.Second), UpdatedAt: now, @@ -186,7 +187,7 @@ func TestCreateExecution_AndGet(t *testing.T) { // Need a task first. tk := &task.Task{ - ID: "etask", Name: "E", Claude: task.ClaudeConfig{Instructions: "x"}, + ID: "etask", Name: "E", Agent: task.AgentConfig{Type: "claude", Instructions: "x"}, Priority: task.PriorityNormal, Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"}, Tags: []string{}, DependsOn: []string{}, State: task.StatePending, CreatedAt: now, UpdatedAt: now, @@ -227,7 +228,7 @@ func TestListExecutions(t *testing.T) { db := testDB(t) now := time.Now().UTC() tk := &task.Task{ - ID: "ltask", Name: "L", Claude: task.ClaudeConfig{Instructions: "x"}, + ID: "ltask", Name: "L", Agent: task.AgentConfig{Type: "claude", Instructions: "x"}, Priority: task.PriorityNormal, Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"}, Tags: []string{}, DependsOn: []string{}, State: task.StatePending, CreatedAt: now, UpdatedAt: now, @@ -260,7 +261,7 @@ func TestDB_UpdateTask(t *testing.T) { ID: "upd-1", Name: "Original Name", Description: "original desc", - Claude: task.ClaudeConfig{Model: "sonnet", Instructions: "original"}, + Agent: task.AgentConfig{Type: "claude", Model: "sonnet", Instructions: "original"}, Priority: task.PriorityNormal, Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"}, Tags: []string{"old"}, @@ -277,7 +278,7 @@ func TestDB_UpdateTask(t *testing.T) { u := TaskUpdate{ Name: "Updated Name", Description: "updated desc", - Config: task.ClaudeConfig{Model: "opus", Instructions: "updated"}, + Config: task.AgentConfig{Type: "claude", Model: "opus", Instructions: "updated"}, Priority: task.PriorityHigh, TimeoutNS: int64(15 * time.Minute), Retry: task.RetryConfig{MaxAttempts: 3, Backoff: "exponential"}, @@ -298,8 +299,8 @@ func TestDB_UpdateTask(t *testing.T) { if got.Description != "updated desc" { t.Errorf("description: want 'updated desc', got %q", got.Description) } - if got.Claude.Model != "opus" { - t.Errorf("model: want 'opus', got %q", got.Claude.Model) + if got.Agent.Model != "opus" { + t.Errorf("model: want 'opus', got %q", got.Agent.Model) } if got.Priority != task.PriorityHigh { t.Errorf("priority: want 'high', got %q", got.Priority) @@ -344,7 +345,7 @@ func TestRejectTask(t *testing.T) { db := testDB(t) now := time.Now().UTC() tk := &task.Task{ - ID: "reject-1", Name: "R", Claude: task.ClaudeConfig{Instructions: "x"}, + ID: "reject-1", Name: "R", Agent: task.AgentConfig{Type: "claude", Instructions: "x"}, Priority: task.PriorityNormal, Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"}, Tags: []string{}, DependsOn: []string{}, State: task.StateReady, CreatedAt: now, UpdatedAt: now, @@ -381,7 +382,7 @@ func TestUpdateExecution(t *testing.T) { db := testDB(t) now := time.Now().UTC() tk := &task.Task{ - ID: "utask", Name: "U", Claude: task.ClaudeConfig{Instructions: "x"}, + ID: "utask", Name: "U", Agent: task.AgentConfig{Type: "claude", Instructions: "x"}, Priority: task.PriorityNormal, Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"}, Tags: []string{}, DependsOn: []string{}, State: task.StatePending, CreatedAt: now, UpdatedAt: now, @@ -424,7 +425,7 @@ func TestUpdateExecution(t *testing.T) { func makeTestTask(id string, now time.Time) *task.Task { return &task.Task{ - ID: id, Name: "T-" + id, Claude: task.ClaudeConfig{Instructions: "x"}, + ID: id, Name: "T-" + id, Agent: task.AgentConfig{Type: "claude", Instructions: "x"}, Priority: task.PriorityNormal, Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"}, Tags: []string{}, DependsOn: []string{}, State: task.StatePending, CreatedAt: now, UpdatedAt: now, -- cgit v1.2.3