test(config): add custom commands order test (#1536)

This commit is contained in:
Wang Bing-hua
2025-11-20 01:37:55 +08:00
committed by GitHub
parent 8de6a36d86
commit cdee1c14d9

View File

@@ -1892,4 +1892,24 @@ mod test {
config.opt = CommandLineArgs::parse_from(["topgrade", "--remote-host-limit", "other_hostname"]);
assert!(!config.should_execute_remote(Ok("hostname".to_string()), "user@remote_hostname"));
}
/// Ensure that custom commands are stored in insertion order.
#[test]
fn test_custom_commands_order() {
let toml_str = r#"
[commands]
z = "cmd_z"
y = "cmd_y"
x = "cmd_x"
"#;
let order: Vec<_> = toml::from_str::<ConfigFile>(toml_str)
.expect("toml parse error")
.commands
.expect("commands field missing")
.keys()
.cloned()
.collect();
assert_eq!(order, vec!["z", "y", "x"]);
}
}