oxedyne/fe2o3/fe2o3_steel/tests/cfg_parse_check.rs
1.4 KiB, 5 runs
created by r1870400018:14360, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | //! Throwaway: parse a real deployed config with this build, the whole way down to its vhosts. |
| 2 | //! |
| 3 | //! Run with `STEEL_CONFIG_CHECK=/path/to/config.jdat cargo test --test cfg_parse_check -- --nocapture`. |
| 4 | //! Unset, it skips. |
| 5 | //! |
| 6 | //! [Written with AI entirely](https://need2know.ai/entirely-ai/code)\ |
| 7 | //! Anthropic Claude |
| 8 | |
| 9 | use oxedyne_fe2o3_core::prelude::*; |
| 10 | use oxedyne_fe2o3_jdat::{ |
| 11 | prelude::*, |
| 12 | cfg::Config, |
| 13 | file::JdatMapFile, |
| 14 | }; |
| 15 | use oxedyne_fe2o3_steel::{ |
| 16 | app::cfg::AppConfig, |
| 17 | srv::cfg::ServerConfig, |
| 18 | }; |
| 19 | |
| 20 | use std::path::Path; |
| 21 | |
| 22 | #[test] |
| 23 | fn parses_a_real_config() -> Outcome<()> { |
| 24 | let path = match std::env::var("STEEL_CONFIG_CHECK") { |
| 25 | Ok(p) => p, |
| 26 | Err(_) => { |
| 27 | println!("STEEL_CONFIG_CHECK unset; skipping."); |
| 28 | return Ok(()); |
| 29 | } |
| 30 | }; |
| 31 | let app_cfg = res!(AppConfig::load(Path::new(&path))); |
| 32 | let server_cfg = res!(ServerConfig::from_datmap(app_cfg.server_cfg.clone())); |
| 33 | let vhosts = res!(server_cfg.get_vhosts()); |
| 34 | println!("PARSED OK: {} ({} vhosts)", path, vhosts.len()); |
| 35 | for vh in &vhosts { |
| 36 | println!( |
| 37 | " {:34} publish = {}", |
| 38 | vh.hostnames.first().map(|s| s.as_str()).unwrap_or("?"), |
| 39 | match &vh.publish { |
| 40 | Some(p) => fmt!("path={} title={:?} dir={} css={}", |
| 41 | p.path, p.title, p.dir, p.css.len()), |
| 42 | None => fmt!("none"), |
| 43 | }, |
| 44 | ); |
| 45 | } |
| 46 | Ok(()) |
| 47 | } |