From b50dd425ca86c142cb3bcfd5d84dce76e049d865 Mon Sep 17 00:00:00 2001 From: acheron Date: Sat, 14 Dec 2024 19:01:39 +0100 Subject: [PATCH] cli: Add tests --- cli/src/config.rs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/cli/src/config.rs b/cli/src/config.rs index 27ff2e52d0..f38100aba5 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -1484,15 +1484,34 @@ mod tests { wallet = \"id.json\" "; - const CUSTOM_CONFIG: &str = " + #[test] + fn parse_custom_cluster_str() { + let config = Config::from_str( + " [provider] - cluster = { http = \"http://my-url.com\", ws = \"ws://my-url.com\" } + cluster = \"http://my-url.com\" wallet = \"id.json\" - "; + ", + ) + .unwrap(); + assert!(!config.features.skip_lint); + + // Make sure the layout of `provider.cluster` stays the same after serialization + assert!(config + .to_string() + .contains(r#"cluster = "http://my-url.com""#)); + } #[test] - fn parse_custom_cluster() { - let config = Config::from_str(CUSTOM_CONFIG).unwrap(); + fn parse_custom_cluster_map() { + let config = Config::from_str( + " + [provider] + cluster = { http = \"http://my-url.com\", ws = \"ws://my-url.com\" } + wallet = \"id.json\" + ", + ) + .unwrap(); assert!(!config.features.skip_lint); }