From cdee1c14d9fb86b6809a7e28c0057b3372ef2c4a Mon Sep 17 00:00:00 2001 From: Wang Bing-hua Date: Thu, 20 Nov 2025 01:37:55 +0800 Subject: [PATCH] test(config): add custom commands order test (#1536) --- src/config.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/config.rs b/src/config.rs index 04291682..fcd8e634 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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::(toml_str) + .expect("toml parse error") + .commands + .expect("commands field missing") + .keys() + .cloned() + .collect(); + + assert_eq!(order, vec!["z", "y", "x"]); + } }