(t *testing.T)
| 116 | } |
| 117 | |
| 118 | func TestSpawnCommandMapsBoundedChildRequest(t *testing.T) { |
| 119 | t.Parallel() |
| 120 | |
| 121 | t.Run("Should map bounded child request", func(t *testing.T) { |
| 122 | t.Parallel() |
| 123 | |
| 124 | var gotRequest AgentSpawnRequest |
| 125 | client := &stubClient{} |
| 126 | deps := newAgentCommandTestDeps(t, client) |
| 127 | client.agentSpawnFn = func( |
| 128 | _ context.Context, |
| 129 | request AgentSpawnRequest, |
| 130 | credentials agentidentity.Credentials, |
| 131 | ) (AgentSpawnRecord, error) { |
| 132 | assertAgentCredentials(t, credentials) |
| 133 | gotRequest = request |
| 134 | ttl := fixedTestNow.Add(2 * time.Minute) |
| 135 | return AgentSpawnRecord{ |
| 136 | Session: SessionRecord{ |
| 137 | ID: "sess-child", |
| 138 | Name: request.Name, |
| 139 | AgentName: request.AgentName, |
| 140 | Provider: request.Provider, |
| 141 | WorkspaceID: "ws-1", |
| 142 | WorkspacePath: "/workspace/project", |
| 143 | Channel: "builders", |
| 144 | Type: session.SessionTypeSpawned, |
| 145 | State: session.StateActive, |
| 146 | CreatedAt: fixedTestNow, |
| 147 | UpdatedAt: fixedTestNow, |
| 148 | }, |
| 149 | Lineage: contract.SessionLineagePayload{ |
| 150 | ParentSessionID: "sess-agent", |
| 151 | RootSessionID: "sess-agent", |
| 152 | SpawnDepth: 1, |
| 153 | SpawnRole: request.SpawnRole, |
| 154 | TTLExpiresAt: &ttl, |
| 155 | AutoStopOnParent: request.AutoStopOnParent, |
| 156 | SpawnBudget: contract.SpawnBudgetPayload{ |
| 157 | MaxChildren: 5, |
| 158 | MaxDepth: 1, |
| 159 | TTLSeconds: request.TTLSeconds, |
| 160 | }, |
| 161 | PermissionPolicy: request.Permissions, |
| 162 | }, |
| 163 | Permissions: request.Permissions, |
| 164 | }, nil |
| 165 | } |
| 166 | |
| 167 | stdout, _, err := executeRootCommand( |
| 168 | t, |
| 169 | deps, |
| 170 | "spawn", |
| 171 | "--agent", |
| 172 | "coder", |
| 173 | "--provider", |
| 174 | "codex", |
| 175 | "--model", |
nothing calls this directly
no test coverage detected