huskies: merge 1030
This commit is contained in:
@@ -22,56 +22,19 @@ use std::collections::HashMap;
|
||||
use std::fs;
|
||||
|
||||
pub(crate) fn tool_create_bug(args: &Value, ctx: &AppContext) -> Result<String, String> {
|
||||
let name = args
|
||||
.get("name")
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or("Missing required argument: name")?;
|
||||
let description = args
|
||||
.get("description")
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or("Missing required argument: description")?;
|
||||
let steps_to_reproduce = args
|
||||
.get("steps_to_reproduce")
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or("Missing required argument: steps_to_reproduce")?;
|
||||
let actual_result = args
|
||||
.get("actual_result")
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or("Missing required argument: actual_result")?;
|
||||
let expected_result = args
|
||||
.get("expected_result")
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or("Missing required argument: expected_result")?;
|
||||
let acceptance_criteria: Vec<String> = args
|
||||
.get("acceptance_criteria")
|
||||
.and_then(|v| serde_json::from_value(v.clone()).ok())
|
||||
.ok_or("Missing required argument: acceptance_criteria")?;
|
||||
if acceptance_criteria.is_empty() {
|
||||
return Err("acceptance_criteria must contain at least one entry".to_string());
|
||||
}
|
||||
const JUNK_AC: &[&str] = &["", "todo", "tbd", "fixme", "xxx", "???"];
|
||||
let all_junk = acceptance_criteria
|
||||
.iter()
|
||||
.all(|ac| JUNK_AC.contains(&ac.trim().to_lowercase().as_str()));
|
||||
if all_junk {
|
||||
return Err(
|
||||
"acceptance_criteria must contain at least one real entry (not just TODO/TBD/FIXME/XXX/???)."
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
let depends_on: Option<Vec<u32>> = args
|
||||
.get("depends_on")
|
||||
.and_then(|v| serde_json::from_value(v.clone()).ok());
|
||||
let req = crate::validation::CreateBugRequest::from_json(args)?;
|
||||
let acs = req.acceptance_criteria_strings();
|
||||
let depends_on = req.depends_on_ids();
|
||||
|
||||
let root = ctx.state.get_project_root()?;
|
||||
let bug_id = create_bug_file(
|
||||
&root,
|
||||
name,
|
||||
description,
|
||||
steps_to_reproduce,
|
||||
actual_result,
|
||||
expected_result,
|
||||
&acceptance_criteria,
|
||||
req.name.as_ref(),
|
||||
req.description.as_str(),
|
||||
req.steps_to_reproduce.as_str(),
|
||||
req.actual_result.as_str(),
|
||||
req.expected_result.as_str(),
|
||||
&acs,
|
||||
depends_on.as_deref(),
|
||||
)?;
|
||||
|
||||
@@ -235,8 +198,8 @@ mod tests {
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(
|
||||
err.contains("empty") || err.contains("whitespace"),
|
||||
"error should mention empty/whitespace, got: {err}"
|
||||
err.contains("EmptyAfterTrim"),
|
||||
"error should mention EmptyAfterTrim, got: {err}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -416,8 +379,8 @@ mod tests {
|
||||
);
|
||||
assert!(result.is_err());
|
||||
assert!(
|
||||
result.unwrap_err().contains("real entry"),
|
||||
"error should mention real entry"
|
||||
result.unwrap_err().contains("TooFewItems"),
|
||||
"error should contain TooFewItems"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user