summaryrefslogtreecommitdiff
path: root/internal/executor/executor_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/executor/executor_test.go')
-rw-r--r--internal/executor/executor_test.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/internal/executor/executor_test.go b/internal/executor/executor_test.go
index ad496e7..933f303 100644
--- a/internal/executor/executor_test.go
+++ b/internal/executor/executor_test.go
@@ -2027,6 +2027,67 @@ func TestPool_DependsOn_NoDeadlock(t *testing.T) {
}
}
+func TestCreateValidationTask_InstructionsIncludeNamedCriteria(t *testing.T) {
+ store := testStore(t)
+ runner := &mockRunner{}
+ runners := map[string]Runner{"claude": runner}
+ logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelError}))
+ pool := NewPool(2, runners, store, logger)
+
+ now := time.Now().UTC()
+ story := &task.Story{
+ ID: "story-named-criteria-1",
+ Name: "Named Criteria Story",
+ Status: task.StoryDeployed,
+ CreatedAt: now,
+ UpdatedAt: now,
+ ValidationJSON: `{
+ "type": "automated",
+ "acceptance_criteria": [
+ {"name": "API returns 200", "verification": "GET /health returns HTTP 200", "test_ref": "TestHealthEndpoint"},
+ {"name": "DB migration applied", "verification": "table users exists", "test_ref": ""},
+ {"name": "Auth header required", "verification": "requests without token get 401"}
+ ]
+ }`,
+ }
+ if err := store.CreateStory(story); err != nil {
+ t.Fatalf("CreateStory: %v", err)
+ }
+
+ pool.createValidationTask(context.Background(), story.ID)
+
+ // Drain the submitted task from results.
+ select {
+ case <-pool.Results():
+ case <-time.After(5 * time.Second):
+ t.Fatal("timed out waiting for validation task result")
+ }
+
+ tasks, err := store.ListTasksByStory(story.ID)
+ if err != nil {
+ t.Fatalf("ListTasksByStory: %v", err)
+ }
+ if len(tasks) != 1 {
+ t.Fatalf("expected 1 validation task, got %d", len(tasks))
+ }
+
+ instructions := tasks[0].Agent.Instructions
+ // Each criterion name must appear as a formatted list item (not merely in raw JSON).
+ for _, line := range []string{
+ "- API returns 200:",
+ "- DB migration applied:",
+ "- Auth header required:",
+ } {
+ if !strings.Contains(instructions, line) {
+ t.Errorf("instructions missing formatted criterion line %q\n\nfull instructions:\n%s", line, instructions)
+ }
+ }
+ // test_ref should appear for criteria that have one.
+ if !strings.Contains(instructions, "TestHealthEndpoint") {
+ t.Errorf("instructions should include test_ref 'TestHealthEndpoint'\n\nfull instructions:\n%s", instructions)
+ }
+}
+
func TestPool_ValidationTask_Fail_SetsNeedsFix(t *testing.T) {
store := testStore(t)
logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelError}))