huskies: merge 1034
This commit is contained in:
@@ -69,17 +69,8 @@ fn strip_front_matter(text: &str) -> (String, String) {
|
||||
/// Returns a friendly message when no match is found.
|
||||
pub(super) fn handle_show(ctx: &CommandContext) -> Option<String> {
|
||||
let num_str = ctx.args.trim();
|
||||
if num_str.is_empty() {
|
||||
return Some(format!(
|
||||
"Usage: `{} show <number>`\n\nDisplays the full text of a story, bug, or spike.",
|
||||
ctx.services.bot_name
|
||||
));
|
||||
}
|
||||
if !num_str.chars().all(|c| c.is_ascii_digit()) {
|
||||
return Some(format!(
|
||||
"Invalid story number: `{num_str}`. Usage: `{} show <number>`",
|
||||
ctx.services.bot_name
|
||||
));
|
||||
if num_str.is_empty() || !num_str.chars().all(|c| c.is_ascii_digit()) {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Find the story by numeric prefix: CRDT → content store.
|
||||
@@ -169,22 +160,32 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn show_command_no_args_returns_usage() {
|
||||
fn show_command_no_args_routes_to_timmy() {
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
let output = show_cmd_with_root(tmp.path(), "").unwrap();
|
||||
let result = show_cmd_with_root(tmp.path(), "");
|
||||
assert!(
|
||||
output.contains("Usage"),
|
||||
"no args should show usage hint: {output}"
|
||||
result.is_none(),
|
||||
"no args should route to LLM (None), not return a usage error: {result:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn show_command_non_numeric_args_returns_error() {
|
||||
fn show_command_non_numeric_args_routes_to_timmy() {
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
let output = show_cmd_with_root(tmp.path(), "abc").unwrap();
|
||||
let result = show_cmd_with_root(tmp.path(), "me the story about the login bug");
|
||||
assert!(
|
||||
output.contains("Invalid"),
|
||||
"non-numeric arg should return error message: {output}"
|
||||
result.is_none(),
|
||||
"natural-language args should route to LLM (None): {result:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn show_command_well_formed_runs_handler() {
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
let result = show_cmd_with_root(tmp.path(), "999");
|
||||
assert!(
|
||||
result.is_some(),
|
||||
"well-formed numeric arg should run the command handler: {result:?}"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user