summaryrefslogtreecommitdiff
path: root/internal/api/claudomator_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/claudomator_test.go')
-rw-r--r--internal/api/claudomator_test.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/internal/api/claudomator_test.go b/internal/api/claudomator_test.go
new file mode 100644
index 0000000..4a2cb00
--- /dev/null
+++ b/internal/api/claudomator_test.go
@@ -0,0 +1,53 @@
+package api
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "testing"
+
+ "task-dashboard/internal/models"
+)
+
+func TestClaudomatorClient_GetActiveStories(t *testing.T) {
+ stories := []models.ClaudomatorStory{
+ {ID: "1", Title: "Story One", Status: "IN_PROGRESS"},
+ {ID: "2", Title: "Story Two", Status: "REVIEW_READY"},
+ {ID: "3", Title: "Story Three", Status: "DRAFT"},
+ }
+
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path != "/api/stories" {
+ http.NotFound(w, r)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ _ = json.NewEncoder(w).Encode(stories)
+ }))
+ defer server.Close()
+
+ client := ClaudomatorHTTPClient{BaseURL: server.URL}
+ result, err := client.GetActiveStories(context.Background())
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+
+ if len(result) != 2 {
+ t.Fatalf("expected 2 active stories, got %d", len(result))
+ }
+
+ statuses := map[string]bool{}
+ for _, s := range result {
+ statuses[s.Status] = true
+ }
+ if !statuses["IN_PROGRESS"] {
+ t.Error("expected IN_PROGRESS story in results")
+ }
+ if !statuses["REVIEW_READY"] {
+ t.Error("expected REVIEW_READY story in results")
+ }
+ if statuses["DRAFT"] {
+ t.Error("DRAFT story should be excluded from results")
+ }
+}