fn merge_toml()

in config-common/src/lib.rs [132:189]


    fn merge_toml() {
        let base = r#"
foo_key = "A"
foo_parent_key = { foo_sub_key = "B" }

[bar_table]
bar_table_key = "C"
bar_table_parent_key = { bar_table_sub_key = "D" }

[[baz_table_array]]
baz_table_array_key = "E"
baz_table_array_parent_key = { baz_table_sub_key = "F" }
"#;
        let mut base: toml::Value = toml::from_str(base).unwrap();

        let patch = r#"
foo_key = "A2"
foo_key_new = "A3"
foo_parent_key = { foo_sub_key = "B2", foo_sub_key2 = "B3" }
foo_parent_key_new = { foo_sub_key = "B4", foo_sub_key2 = "B5" }

[bar_table]
bar_table_key = "C2"
bar_table_key_new = "C3"
bar_table_parent_key = { bar_table_sub_key = "D2", bar_table_sub_key2 = "D3" }
bar_table_parent_key_new = { bar_table_sub_key = "D4", bar_table_sub_key2 = "D5" }

[[baz_table_array]]
baz_table_array_key = "G"
baz_table_array_parent_key = { baz_table_sub_key = "H" }
"#;
        let patch: toml::Value = toml::from_str(patch).unwrap();

        super::merge_toml(&mut base, patch);

        let expected = r#"
foo_key = "A2"
foo_key_new = "A3"
foo_parent_key = { foo_sub_key = "B2", foo_sub_key2 = "B3" }
foo_parent_key_new = { foo_sub_key = "B4", foo_sub_key2 = "B5" }

[bar_table]
bar_table_key = "C2"
bar_table_key_new = "C3"
bar_table_parent_key = { bar_table_sub_key = "D2", bar_table_sub_key2 = "D3" }
bar_table_parent_key_new = { bar_table_sub_key = "D4", bar_table_sub_key2 = "D5" }

[[baz_table_array]]
baz_table_array_key = "E"
baz_table_array_parent_key = { baz_table_sub_key = "F" }

[[baz_table_array]]
baz_table_array_key = "G"
baz_table_array_parent_key = { baz_table_sub_key = "H" }
"#;
        let expected: toml::Value = toml::from_str(expected).unwrap();
        assert_eq!(expected, base);
    }