huskies: merge 584_bug_bot_asks_user_to_run_huskies_init_instead_of_running_wizard_automatically
This commit is contained in:
@@ -59,12 +59,17 @@ fn wizard_generate_reply(ctx: &CommandContext) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Compose a status reply for the `setup` command (no args).
|
/// Compose a status reply for the `setup` command (no args).
|
||||||
|
///
|
||||||
|
/// If no wizard state exists, automatically initializes it so the user does
|
||||||
|
/// not need to run `huskies init` manually.
|
||||||
fn wizard_status_reply(ctx: &CommandContext) -> String {
|
fn wizard_status_reply(ctx: &CommandContext) -> String {
|
||||||
|
if WizardState::load(ctx.project_root).is_none() {
|
||||||
|
WizardState::init_if_missing(ctx.project_root);
|
||||||
|
}
|
||||||
match WizardState::load(ctx.project_root) {
|
match WizardState::load(ctx.project_root) {
|
||||||
Some(state) => format_wizard_state(&state),
|
Some(state) => format_wizard_state(&state),
|
||||||
None => {
|
None => "Unable to initialize setup wizard. Ensure the `.huskies/` directory exists."
|
||||||
"No setup wizard active. Run `huskies init` in the project root to begin.".to_string()
|
.to_string(),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,13 +210,18 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn setup_no_wizard_returns_helpful_message() {
|
fn setup_no_wizard_auto_initializes() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new().unwrap();
|
||||||
|
std::fs::create_dir_all(dir.path().join(".huskies")).unwrap();
|
||||||
let agents = Arc::new(crate::agents::AgentPool::new_test(4000));
|
let agents = Arc::new(crate::agents::AgentPool::new_test(4000));
|
||||||
let rooms = Arc::new(Mutex::new(HashSet::new()));
|
let rooms = Arc::new(Mutex::new(HashSet::new()));
|
||||||
let ctx = make_ctx("", dir.path(), &agents, &rooms);
|
let ctx = make_ctx("", dir.path(), &agents, &rooms);
|
||||||
let result = handle_setup(&ctx).unwrap();
|
let result = handle_setup(&ctx).unwrap();
|
||||||
assert!(result.contains("huskies init"));
|
// Bot should auto-initialize and return wizard status, not ask user to run huskies init.
|
||||||
|
assert!(result.contains("Setup wizard"));
|
||||||
|
assert!(!result.contains("huskies init"));
|
||||||
|
// Wizard state file should now exist.
|
||||||
|
assert!(WizardState::load(dir.path()).is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user