Skip to content

Commit 1379c79

Browse files
style(clippy): use struct update syntax for field_reassign_with_default (#679)
1 parent 4087579 commit 1379c79

3 files changed

Lines changed: 32 additions & 29 deletions

File tree

src/agent_stats.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -378,16 +378,18 @@ mod tests {
378378

379379
#[test]
380380
fn test_append_stats_to_body_opt_out() {
381-
let mut ctx = crate::safeoutputs::ExecutionContext::default();
382-
ctx.agent_stats = Some(AgentStats {
383-
agent_name: "test".to_string(),
384-
model: Some("model".to_string()),
385-
input_tokens: 100,
386-
output_tokens: 50,
387-
duration_seconds: 10.0,
388-
tool_calls: 1,
389-
turns: 1,
390-
});
381+
let ctx = crate::safeoutputs::ExecutionContext {
382+
agent_stats: Some(AgentStats {
383+
agent_name: "test".to_string(),
384+
model: Some("model".to_string()),
385+
input_tokens: 100,
386+
output_tokens: 50,
387+
duration_seconds: 10.0,
388+
tool_calls: 1,
389+
turns: 1,
390+
}),
391+
..Default::default()
392+
};
391393
assert_eq!(append_stats_to_body("body", &ctx, false), "body");
392394
}
393395

@@ -399,16 +401,18 @@ mod tests {
399401

400402
#[test]
401403
fn test_append_stats_to_body_with_stats() {
402-
let mut ctx = crate::safeoutputs::ExecutionContext::default();
403-
ctx.agent_stats = Some(AgentStats {
404-
agent_name: "test".to_string(),
405-
model: Some("model".to_string()),
406-
input_tokens: 100,
407-
output_tokens: 50,
408-
duration_seconds: 10.0,
409-
tool_calls: 1,
410-
turns: 1,
411-
});
404+
let ctx = crate::safeoutputs::ExecutionContext {
405+
agent_stats: Some(AgentStats {
406+
agent_name: "test".to_string(),
407+
model: Some("model".to_string()),
408+
input_tokens: 100,
409+
output_tokens: 50,
410+
duration_seconds: 10.0,
411+
tool_calls: 1,
412+
turns: 1,
413+
}),
414+
..Default::default()
415+
};
412416
let result = append_stats_to_body("body", &ctx, true);
413417
assert!(result.starts_with("body"));
414418
assert!(result.contains("test"));

src/execute.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,8 +1322,7 @@ mod tests {
13221322
let ndjson = r#"{"name":"create-work-item","title":"Test work item title","description":"This is a test description that is long enough to pass validation checks"}"#;
13231323
tokio::fs::write(&safe_output_path, ndjson).await.unwrap();
13241324

1325-
let mut ctx = ExecutionContext::default();
1326-
ctx.dry_run = true;
1325+
let ctx = ExecutionContext { dry_run: true, ..Default::default() };
13271326

13281327
let results = execute_safe_outputs(temp_dir.path(), &ctx).await.unwrap();
13291328
assert_eq!(results.len(), 1);
@@ -1352,8 +1351,7 @@ mod tests {
13521351
.join("\n");
13531352
tokio::fs::write(&safe_output_path, ndjson).await.unwrap();
13541353

1355-
let mut ctx = ExecutionContext::default();
1356-
ctx.dry_run = true;
1354+
let ctx = ExecutionContext { dry_run: true, ..Default::default() };
13571355

13581356
let results = execute_safe_outputs(temp_dir.path(), &ctx).await.unwrap();
13591357
assert_eq!(results.len(), 2);
@@ -1443,8 +1441,7 @@ mod tests {
14431441
"reason": "Could not find the required data to complete the analysis"
14441442
});
14451443

1446-
let mut ctx = ExecutionContext::default();
1447-
ctx.dry_run = true;
1444+
let ctx = ExecutionContext { dry_run: true, ..Default::default() };
14481445

14491446
let result = execute_safe_output(&entry, &ctx).await;
14501447
assert!(result.is_ok(), "dispatch should succeed");

src/safeoutputs/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,9 +1190,11 @@ mod tests {
11901190
repository_name: Option<&str>,
11911191
allowed: std::collections::HashMap<String, String>,
11921192
) -> ExecutionContext {
1193-
let mut ctx = ExecutionContext::default();
1194-
ctx.repository_name = repository_name.map(|s| s.to_string());
1195-
ctx.allowed_repositories = allowed;
1193+
let ctx = ExecutionContext {
1194+
repository_name: repository_name.map(|s| s.to_string()),
1195+
allowed_repositories: allowed,
1196+
..Default::default()
1197+
};
11961198
ctx
11971199
}
11981200

0 commit comments

Comments
 (0)