wip: xml parser

This commit is contained in:
Jean-Gabriel Gill-Couture
2024-10-04 11:26:55 -04:00
parent 407bdbc032
commit 6a5ebdbac7
4 changed files with 40 additions and 69 deletions

View File

@@ -17,4 +17,4 @@ log = { workspace = true }
env_logger = { workspace = true }
async-trait = { workspace = true }
cidr = { workspace = true }
minidom = { workspace = true }
xml_dom = { workspace = true }

View File

@@ -10,11 +10,12 @@ impl OPNSenseXmlConfigEditor {
#[cfg(test)]
mod test {
use minidom::Element;
use std::fs;
use std::io::{BufReader, Read};
use std::process::Command;
use xml_dom::parser::read_xml;
// #[test]
// fn should_not_alter_config() {
// let path = "./private_repos/affilium_mcd/private/config.xml";
@@ -34,10 +35,9 @@ mod test {
let file_str = fs::read_to_string(path).expect("Failed to read file");
// Parse with minidom
let root: Element = file_str.parse().unwrap();
let root = read_xml(&file_str).unwrap();
// Save file with suffix name
fs::write(&output_path, String::from(&root)).expect("Failed to write output file");
assert_eq!(&root.to_string(), &file_str);
}
}