diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-26 04:57:37 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-26 04:57:37 +0000 |
| commit | 5410069ae36bc5df5d7cc950fce5d2c5a251618a (patch) | |
| tree | 27af725f0d323cb9f7f318a1e8553af2262d7084 /internal/api/stories_test.go | |
| parent | b6e420a62a3e7e81a6f5d2819f12cca11b82e572 (diff) | |
fix: set RepositoryURL on tasks created via story approve
handleApproveStory was creating tasks without RepositoryURL, causing
executions to fail with "task has no repository_url". Now looks up
the project's RemoteURL and sets it on all tasks and subtasks.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/api/stories_test.go')
| -rw-r--r-- | internal/api/stories_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/api/stories_test.go b/internal/api/stories_test.go index 17bea07..53d15eb 100644 --- a/internal/api/stories_test.go +++ b/internal/api/stories_test.go @@ -205,6 +205,58 @@ func TestHandleStoryApprove_WiresDepends(t *testing.T) { } } +func TestHandleStoryApprove_SetsRepositoryURL(t *testing.T) { + srv, store := testServer(t) + + proj := &task.Project{ + ID: "proj-repo", + Name: "claudomator", + RemoteURL: "/site/git.terst.org/repos/claudomator.git", + LocalPath: "/workspace/claudomator", + } + if err := store.CreateProject(proj); err != nil { + t.Fatalf("CreateProject: %v", err) + } + + body := `{ + "name": "Repo URL Story", + "branch_name": "story/repo-url", + "project_id": "proj-repo", + "tasks": [ + {"name": "Task A", "instructions": "do A", "subtasks": []}, + {"name": "Task B", "instructions": "do B", "subtasks": [ + {"name": "Sub B1", "instructions": "do B1"} + ]} + ], + "validation": {"type": "build", "steps": ["go build ./..."], "success_criteria": "ok"} + }` + req := httptest.NewRequest("POST", "/api/stories/approve", bytes.NewBufferString(body)) + req.Header.Set("Content-Type", "application/json") + w := httptest.NewRecorder() + srv.mux.ServeHTTP(w, req) + + if w.Code != http.StatusCreated { + t.Fatalf("expected 201, got %d: %s", w.Code, w.Body.String()) + } + + var resp struct { + TaskIDs []string `json:"task_ids"` + } + if err := json.NewDecoder(w.Body).Decode(&resp); err != nil { + t.Fatalf("decode: %v", err) + } + + for _, id := range resp.TaskIDs { + tk, err := store.GetTask(id) + if err != nil { + t.Fatalf("GetTask %s: %v", id, err) + } + if tk.RepositoryURL != proj.RemoteURL { + t.Errorf("task %s RepositoryURL: want %q, got %q", tk.ID, proj.RemoteURL, tk.RepositoryURL) + } + } +} + func TestHandleStoryDeploymentStatus(t *testing.T) { srv, store := testServer(t) |
