diff options
Diffstat (limited to 'internal/executor/nativerunner_test.go')
| -rw-r--r-- | internal/executor/nativerunner_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/internal/executor/nativerunner_test.go b/internal/executor/nativerunner_test.go index b081b8e..afdb49d 100644 --- a/internal/executor/nativerunner_test.go +++ b/internal/executor/nativerunner_test.go @@ -19,6 +19,7 @@ import ( "github.com/thepeterstone/claudomator/internal/llm" "github.com/thepeterstone/claudomator/internal/provider/openaicompat" "github.com/thepeterstone/claudomator/internal/storage" + "github.com/thepeterstone/claudomator/internal/story" "github.com/thepeterstone/claudomator/internal/task" ) @@ -237,6 +238,50 @@ func TestNativeRunner_Run_ToolLoop_SpawnSubtask_RolePassthrough(t *testing.T) { } } +// TestNativeRunner_Run_ToolLoop_ProposeEpic is an end-to-end-ish test (fake +// LLM server, real agentloop.Loop/tools.go dispatch, real storeChannel) +// proving a propose_epic tool call reaches AgentChannel.ProposeEpic +// correctly through internal/agentloop/tools.go's dispatchTool, and from +// there through storeChannel.ProposeEpic into a created epic with the given +// stories grouped under it — mirroring the spawn_subtask role-passthrough +// coverage above (Phase 6) for this phase's new tool (Phase 7c). +func TestNativeRunner_Run_ToolLoop_ProposeEpic(t *testing.T) { + srv := fakeChatServer(t, []fakeTurn{ + {toolCalls: []llm.ToolCall{toolCall("c1", "propose_epic", `{"name":"Checkout revamp","description":"relaunch","story_ids":["story-1","story-2"]}`)}}, + {content: "finished"}, + }) + defer srv.Close() + + r := newLocalRunner(t, srv) + tt := localTask() + store := &fakeChannelStore{ + stories: map[string]*story.Story{ + "story-1": {ID: "story-1", Name: "s1"}, + "story-2": {ID: "story-2", Name: "s2"}, + }, + } + ch := newStoreChannel(store, tt.ID) + exec := &storage.Execution{ID: uuid.New().String(), TaskID: tt.ID} + + if err := r.Run(context.Background(), tt, exec, ch); err != nil { + t.Fatalf("Run: %v", err) + } + + if len(store.epics) != 1 { + t.Fatalf("expected 1 created epic, got %d", len(store.epics)) + } + var epicID string + for id, e := range store.epics { + epicID = id + if e.Name != "Checkout revamp" || e.Description != "relaunch" { + t.Errorf("epic fields not propagated: %+v", e) + } + } + if store.stories["story-1"].EpicID != epicID || store.stories["story-2"].EpicID != epicID { + t.Errorf("stories not grouped under the proposed epic: %+v / %+v", store.stories["story-1"], store.stories["story-2"]) + } +} + func TestNativeRunner_Run_RecordProgress(t *testing.T) { srv := fakeChatServer(t, []fakeTurn{ {toolCalls: []llm.ToolCall{toolCall("c1", "record_progress", `{"message":"halfway there"}`)}}, |
