huskies: merge 1034
This commit is contained in:
@@ -13,17 +13,8 @@ use std::path::{Path, PathBuf};
|
||||
/// recently modified agent log file for that story.
|
||||
pub(super) fn handle_logs(ctx: &CommandContext) -> Option<String> {
|
||||
let num_str = ctx.args.trim();
|
||||
if num_str.is_empty() {
|
||||
return Some(format!(
|
||||
"Usage: `{} logs <number>`\n\nShows the last agent log lines for a story.",
|
||||
ctx.services.bot_name
|
||||
));
|
||||
}
|
||||
if !num_str.chars().all(|c| c.is_ascii_digit()) {
|
||||
return Some(format!(
|
||||
"Invalid story number: `{num_str}`. Usage: `{} logs <number>`",
|
||||
ctx.services.bot_name
|
||||
));
|
||||
if num_str.is_empty() || !num_str.chars().all(|c| c.is_ascii_digit()) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let story_id = match find_story_id_by_number(num_str) {
|
||||
@@ -155,22 +146,32 @@ mod tests {
|
||||
// -- input validation ---------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn logs_no_args_returns_usage() {
|
||||
fn logs_no_args_routes_to_timmy() {
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
let output = logs_cmd(tmp.path(), "").unwrap();
|
||||
let result = logs_cmd(tmp.path(), "");
|
||||
assert!(
|
||||
output.contains("Usage"),
|
||||
"no args should show usage: {output}"
|
||||
result.is_none(),
|
||||
"no args should route to LLM (None): {result:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn logs_non_numeric_returns_error() {
|
||||
fn logs_non_numeric_routes_to_timmy() {
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
let output = logs_cmd(tmp.path(), "abc").unwrap();
|
||||
let result = logs_cmd(tmp.path(), "for the login story");
|
||||
assert!(
|
||||
output.contains("Invalid"),
|
||||
"non-numeric arg should return error: {output}"
|
||||
result.is_none(),
|
||||
"natural-language args should route to LLM (None): {result:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn logs_well_formed_runs_handler() {
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
let result = logs_cmd(tmp.path(), "99999");
|
||||
assert!(
|
||||
result.is_some(),
|
||||
"well-formed numeric arg should run the command handler: {result:?}"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user