diff options
| author | Claudomator Agent <agent@claudomator> | 2026-03-16 21:02:07 +0000 |
|---|---|---|
| committer | Claudomator Agent <agent@claudomator> | 2026-03-16 21:02:07 +0000 |
| commit | 26dc313f16a2827b0f7a4651f495f36f669cea73 (patch) | |
| tree | da8fcda11d986cf01b7cd75cee7abc6894287327 /internal/api/server_test.go | |
| parent | b8381507ff61c7fb69a91490a9fd58403da8c0fa (diff) | |
feat: expose project field in API and CLI
- POST /api/tasks now reads and stores the project field from request body
- GET /api/tasks/{id} returns project in response (via Task struct json tags)
- list command: adds PROJECT column to tabwriter output
- status command: prints Project line when non-empty
- Tests: TestProject_RoundTrip (API), TestListTasks_ShowsProject, TestStatusCmd_ShowsProject (CLI)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/api/server_test.go')
| -rw-r--r-- | internal/api/server_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/internal/api/server_test.go b/internal/api/server_test.go index 83f83f4..696aca3 100644 --- a/internal/api/server_test.go +++ b/internal/api/server_test.go @@ -398,6 +398,49 @@ func TestCreateTask_ValidationFailure(t *testing.T) { } } +func TestProject_RoundTrip(t *testing.T) { + srv, _ := testServer(t) + + payload := `{ + "name": "Project Task", + "project": "test-project", + "agent": { + "type": "claude", + "instructions": "do the thing", + "model": "sonnet" + } + }` + req := httptest.NewRequest("POST", "/api/tasks", bytes.NewBufferString(payload)) + req.Header.Set("Content-Type", "application/json") + w := httptest.NewRecorder() + srv.Handler().ServeHTTP(w, req) + + if w.Code != http.StatusCreated { + t.Fatalf("create: want 201, got %d; body: %s", w.Code, w.Body.String()) + } + + var created task.Task + json.NewDecoder(w.Body).Decode(&created) + if created.Project != "test-project" { + t.Errorf("create response: project want 'test-project', got %q", created.Project) + } + + // GET the task and verify project is persisted + req2 := httptest.NewRequest("GET", "/api/tasks/"+created.ID, nil) + w2 := httptest.NewRecorder() + srv.Handler().ServeHTTP(w2, req2) + + if w2.Code != http.StatusOK { + t.Fatalf("get: want 200, got %d; body: %s", w2.Code, w2.Body.String()) + } + + var fetched task.Task + json.NewDecoder(w2.Body).Decode(&fetched) + if fetched.Project != "test-project" { + t.Errorf("get response: project want 'test-project', got %q", fetched.Project) + } +} + func TestListTasks_Empty(t *testing.T) { srv, _ := testServer(t) |
