()
| 1226 | |
| 1227 | #[tokio::test] |
| 1228 | async fn test_container_configuration() { |
| 1229 | // The agent network name is derived from the task ID in create_test_task() |
| 1230 | let agent_network = "tsk-agent-test-task-id"; |
| 1231 | let mock_client = Arc::new(TrackedDockerClient { |
| 1232 | inspect_container_response: serde_json::json!({ |
| 1233 | "State": { "Running": true }, |
| 1234 | "NetworkSettings": { |
| 1235 | "Networks": { |
| 1236 | agent_network: { "IPAddress": "172.18.0.2" } |
| 1237 | } |
| 1238 | } |
| 1239 | }) |
| 1240 | .to_string(), |
| 1241 | ..Default::default() |
| 1242 | }); |
| 1243 | let ctx = AppContext::builder().build(); |
| 1244 | let manager = DockerManager::new(&ctx, mock_client.clone(), None); |
| 1245 | |
| 1246 | let task = create_test_task(false); |
| 1247 | let agent = crate::agent::ClaudeAgent::with_tsk_env(ctx.tsk_env()); |
| 1248 | let _ = manager.run_task_container("tsk/base", &task, &agent).await; |
| 1249 | |
| 1250 | let create_calls = mock_client.create_container_calls.lock().unwrap(); |
| 1251 | assert_eq!(create_calls.len(), 2); // One for proxy, one for task container |
| 1252 | |
| 1253 | // Check proxy container config (proxy manager creates this) |
| 1254 | let pcn = default_proxy_container_name(); |
| 1255 | let (proxy_options, _proxy_config) = &create_calls[0]; |
| 1256 | assert_eq!(proxy_options.as_ref().unwrap().name, Some(pcn.clone())); |
| 1257 | |
| 1258 | // Check task container config |
| 1259 | let (options, config) = &create_calls[1]; |
| 1260 | |
| 1261 | assert!( |
| 1262 | options |
| 1263 | .as_ref() |
| 1264 | .unwrap() |
| 1265 | .name |
| 1266 | .as_ref() |
| 1267 | .unwrap() |
| 1268 | .starts_with("tsk-") |
| 1269 | ); |
| 1270 | assert_eq!( |
| 1271 | options.as_ref().unwrap().name, |
| 1272 | Some("tsk-test-task-id".to_string()) |
| 1273 | ); |
| 1274 | assert_eq!(config.image, Some("tsk/base".to_string())); |
| 1275 | assert_eq!(config.working_dir, Some("/workspace/default".to_string())); |
| 1276 | // User is set directly |
| 1277 | assert_eq!(config.user, Some(CONTAINER_USER.to_string())); |
| 1278 | |
| 1279 | // Check that command includes the agent command |
| 1280 | let actual_cmd = config.cmd.as_ref().unwrap(); |
| 1281 | assert_eq!(actual_cmd.len(), 3); |
| 1282 | assert_eq!(actual_cmd[0], "sh"); |
| 1283 | assert_eq!(actual_cmd[1], "-c"); |
| 1284 | assert!(actual_cmd[2].contains("claude")); |
| 1285 |
nothing calls this directly
no test coverage detected