summaryrefslogtreecommitdiff
path: root/internal/executor/channel_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/executor/channel_test.go')
-rw-r--r--internal/executor/channel_test.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/internal/executor/channel_test.go b/internal/executor/channel_test.go
index 23f0661..a2e7c70 100644
--- a/internal/executor/channel_test.go
+++ b/internal/executor/channel_test.go
@@ -338,6 +338,65 @@ func TestStoreChannel_SpawnSubtask_DependsOnDefaultsEmpty(t *testing.T) {
}
}
+// TestStoreChannel_SpawnSubtask_SetsAcceptanceCriteria proves a caller can
+// state what a spawned subtask's work must satisfy.
+func TestStoreChannel_SpawnSubtask_SetsAcceptanceCriteria(t *testing.T) {
+ store := &fakeChannelStore{}
+ ch := newStoreChannel(store, "parent-task-1")
+
+ id, err := ch.SpawnSubtask(context.Background(), agentchannel.SubtaskSpec{
+ Name: "step 1",
+ Instructions: "do the thing",
+ AcceptanceCriteria: []string{"tests pass", "no new lint warnings"},
+ })
+ if err != nil {
+ t.Fatalf("spawn subtask: %v", err)
+ }
+
+ var got *task.Task
+ for _, ct := range store.createdTasks {
+ if ct.ID == id {
+ got = ct
+ }
+ }
+ if got == nil {
+ t.Fatal("subtask not found in store.createdTasks")
+ }
+ if len(got.AcceptanceCriteria) != 2 || got.AcceptanceCriteria[0] != "tests pass" || got.AcceptanceCriteria[1] != "no new lint warnings" {
+ t.Errorf("AcceptanceCriteria: want [tests pass, no new lint warnings], got %+v", got.AcceptanceCriteria)
+ }
+}
+
+// TestStoreChannel_SpawnSubtask_AcceptanceCriteriaDefaultsEmpty proves the
+// backward-compatible default: a caller that never sets AcceptanceCriteria
+// (every pre-existing caller) gets a child task with none, exactly as before
+// this change.
+func TestStoreChannel_SpawnSubtask_AcceptanceCriteriaDefaultsEmpty(t *testing.T) {
+ store := &fakeChannelStore{}
+ ch := newStoreChannel(store, "parent-task-1")
+
+ id, err := ch.SpawnSubtask(context.Background(), agentchannel.SubtaskSpec{
+ Name: "solo step",
+ Instructions: "do the thing",
+ })
+ if err != nil {
+ t.Fatalf("spawn subtask: %v", err)
+ }
+
+ var got *task.Task
+ for _, ct := range store.createdTasks {
+ if ct.ID == id {
+ got = ct
+ }
+ }
+ if got == nil {
+ t.Fatal("subtask not found in store.createdTasks")
+ }
+ if len(got.AcceptanceCriteria) != 0 {
+ t.Errorf("expected empty AcceptanceCriteria by default, got %v", got.AcceptanceCriteria)
+ }
+}
+
func TestStoreChannel_RecordProgress_EmitsAgentMessage(t *testing.T) {
store := &fakeChannelStore{}
ch := newStoreChannel(store, "task-1")