summaryrefslogtreecommitdiff
path: root/internal/api/stories_test.go
diff options
context:
space:
mode:
authorClaudomator Agent <agent@claudomator.dev>2026-03-23 07:12:08 +0000
committerClaudomator Agent <agent@claudomator.dev>2026-03-23 07:12:08 +0000
commitb2e77009c55ba0f07bb9ff904d9f2f6cc9ff0ee2 (patch)
treefd031bba34b186ef236600bee1f9ece34fb53109 /internal/api/stories_test.go
parentbc62c3545bbcf3f9ccc508cdc43ce9ffdb5dfad0 (diff)
feat: Phase 4 — story-aware execution, branch clone, story completion check, deployment status
- ContainerRunner: add Store field; clone with --reference when story has a local project path; checkout story branch after clone; push to story branch instead of HEAD - executor.Store interface: add GetStory, ListTasksByStory, UpdateStoryStatus - Pool.handleRunResult: trigger checkStoryCompletion when a story task succeeds - Pool.checkStoryCompletion: transitions story to SHIPPABLE when all tasks done - serve.go: wire Store into each ContainerRunner - stories.go: update createStoryBranch to fetch+checkout from origin/master base; add GET /api/stories/{id}/deployment-status endpoint - server.go: register deployment-status route - Tests: TestPool_CheckStoryCompletion_AllComplete/PartialComplete, TestHandleStoryDeploymentStatus 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.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/internal/api/stories_test.go b/internal/api/stories_test.go
index cf522e1..17bea07 100644
--- a/internal/api/stories_test.go
+++ b/internal/api/stories_test.go
@@ -7,7 +7,9 @@ import (
"net/http/httptest"
"strings"
"testing"
+ "time"
+ "github.com/thepeterstone/claudomator/internal/deployment"
"github.com/thepeterstone/claudomator/internal/task"
)
@@ -202,3 +204,46 @@ func TestHandleStoryApprove_WiresDepends(t *testing.T) {
t.Errorf("task3.DependsOn: want [%s], got %v", task2.ID, task3.DependsOn)
}
}
+
+func TestHandleStoryDeploymentStatus(t *testing.T) {
+ srv, store := testServer(t)
+
+ // Create a story.
+ now := time.Now().UTC()
+ story := &task.Story{
+ ID: "deploy-story-1",
+ Name: "Deploy Status Story",
+ Status: task.StoryInProgress,
+ CreatedAt: now,
+ UpdatedAt: now,
+ }
+ if err := store.CreateStory(story); err != nil {
+ t.Fatalf("CreateStory: %v", err)
+ }
+
+ // Request deployment status — no tasks yet.
+ req := httptest.NewRequest("GET", "/api/stories/deploy-story-1/deployment-status", nil)
+ w := httptest.NewRecorder()
+ srv.mux.ServeHTTP(w, req)
+
+ if w.Code != http.StatusOK {
+ t.Fatalf("expected 200, got %d: %s", w.Code, w.Body.String())
+ }
+
+ var status deployment.Status
+ if err := json.NewDecoder(w.Body).Decode(&status); err != nil {
+ t.Fatalf("decode: %v", err)
+ }
+ // No tasks → no commits → IncludesFix = false (nothing to check).
+ if status.IncludesFix {
+ t.Error("expected IncludesFix=false when no commits")
+ }
+
+ // 404 for unknown story.
+ req2 := httptest.NewRequest("GET", "/api/stories/nonexistent/deployment-status", nil)
+ w2 := httptest.NewRecorder()
+ srv.mux.ServeHTTP(w2, req2)
+ if w2.Code != http.StatusNotFound {
+ t.Errorf("expected 404 for unknown story, got %d", w2.Code)
+ }
+}