From 5081b0c014d8e82e7be1907441c246fbd01ca21e Mon Sep 17 00:00:00 2001 From: Claudomator Agent Date: Sun, 22 Mar 2026 00:56:54 +0000 Subject: feat: Phase 3 — stories data model, ValidStoryTransition, storage CRUD, API endpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - internal/task/story.go: Story struct, StoryState constants, ValidStoryTransition - internal/task/task.go: add StoryID field - internal/storage/db.go: stories table + story_id on tasks migrations; CreateStory, GetStory, ListStories, UpdateStoryStatus, ListTasksByStory; update all task SELECT/INSERT to include story_id; scanTask extended with sql.NullString for story_id; added modernc timestamp format to GetMaxUpdatedAt - internal/storage/sqlite_cgo.go + sqlite_nocgo.go: build-tag based driver selection (mattn/go-sqlite3 with CGO, modernc.org/sqlite pure-Go fallback) so tests run without a C compiler - internal/api/stories.go: GET/POST /api/stories, GET /api/stories/{id}, GET/POST /api/stories/{id}/tasks (auto-wires depends_on chain), PUT /api/stories/{id}/status (validates transition) - internal/api/server.go: register all story routes - go.mod/go.sum: add modernc.org/sqlite pure-Go dependency Co-Authored-By: Claude Sonnet 4.6 --- internal/task/story_test.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 internal/task/story_test.go (limited to 'internal/task/story_test.go') diff --git a/internal/task/story_test.go b/internal/task/story_test.go new file mode 100644 index 0000000..38d0290 --- /dev/null +++ b/internal/task/story_test.go @@ -0,0 +1,42 @@ +package task + +import "testing" + +func TestValidStoryTransition_Valid(t *testing.T) { + cases := []struct { + from StoryState + to StoryState + }{ + {StoryPending, StoryInProgress}, + {StoryInProgress, StoryShippable}, + {StoryInProgress, StoryNeedsFix}, + {StoryNeedsFix, StoryInProgress}, + {StoryShippable, StoryDeployed}, + {StoryDeployed, StoryValidating}, + {StoryValidating, StoryReviewReady}, + {StoryValidating, StoryNeedsFix}, + } + for _, tc := range cases { + if !ValidStoryTransition(tc.from, tc.to) { + t.Errorf("expected valid transition %s → %s", tc.from, tc.to) + } + } +} + +func TestValidStoryTransition_Invalid(t *testing.T) { + cases := []struct { + from StoryState + to StoryState + }{ + {StoryPending, StoryDeployed}, + {StoryReviewReady, StoryPending}, + {StoryReviewReady, StoryInProgress}, + {StoryReviewReady, StoryShippable}, + {StoryShippable, StoryPending}, + } + for _, tc := range cases { + if ValidStoryTransition(tc.from, tc.to) { + t.Errorf("expected invalid transition %s → %s", tc.from, tc.to) + } + } +} -- cgit v1.2.3