rust-config: demonstrate a bug when falling back to non-trivial default values
authorRaphaël Gomès <rgomes@octobus.net>
Tue, 08 Aug 2023 14:14:00 +0200
changeset 50991 d7b2701f17fa
parent 50990 4c5f6e95df84
child 50992 58390f59826f
rust-config: demonstrate a bug when falling back to non-trivial default values The default value (when the user hasn't configured anything) is not run through the value parser, causing a programming error to happen because of type mismatch. This will be fixed in the next commit.
rust/hg-core/src/config/mod.rs
--- a/rust/hg-core/src/config/mod.rs	Fri Aug 18 14:34:29 2023 +0200
+++ b/rust/hg-core/src/config/mod.rs	Tue Aug 08 14:14:00 2023 +0200
@@ -773,4 +773,13 @@
         assert!(config.get_u32(b"section2", b"not-count").is_err());
         assert!(config.get_byte_size(b"section2", b"not-size").is_err());
     }
+
+    #[test]
+    fn test_default_parse() {
+        let config = Config::load_from_explicit_sources(vec![])
+            .expect("expected valid config");
+        let ret = config.get_byte_size(b"cmdserver", b"max-log-size");
+        // FIXME should be `is_ok`
+        assert!(ret.is_err(), "{:?}", ret);
+    }
 }