use crate::helpers::client::E2eClient;
use crate::helpers::config::ConfigManager;
use crate::helpers::constants::{category_enabled, Suite};
use crate::helpers::report::TestReport;
use crate::run_test;
pub fn run(client: &E2eClient, suite: Suite, config: &ConfigManager, report: &mut TestReport) {
if !category_enabled("reload") || !suite.is_all() {
return;
}
eprintln!();
eprintln!("\x1b[1mHot Reload Tests\x1b[0m");
eprintln!("--------------------------------------------");
run_test!(report, "reload", "Reload: success response", {
let (status, body) = client.admin_reload();
assert_eq!(status, 200);
assert_eq!(body["success"], true, "Expected success=true: {}", body);
});
config.backup_current();
config.set_max_entries(9999);
run_test!(report, "reload", "Reload: picks up new max_entries", {
let (status, body) = client.admin_reload();
assert_eq!(status, 200);
assert_eq!(body["success"], true);
let (status, stats) = client.stats();
assert_eq!(status, 200);
let max_entries = stats["cache"]["max_entries"].as_u64().unwrap_or(0);
assert_eq!(
max_entries, 9999,
"Expected max_entries=9999 after reload, got {max_entries}"
);
});
run_test!(report, "reload", "Reload: reports reloaded sections", {
let (_, body) = client.admin_reload();
let reloaded = body["reloaded"].as_array().map(|a| a.len()).unwrap_or(0);
assert!(reloaded > 0, "Expected reloaded sections > 0");
});
config.restore_reload_backup();
run_test!(report, "reload", "Reload: restored config", {
let (status, body) = client.admin_reload();
assert_eq!(status, 200);
assert_eq!(body["success"], true);
});
eprintln!("--------------------------------------------");
}