use orion_conf::ConfigIO;
use std::path::Path;
#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq)]
struct TestConfig {
name: String,
value: i32,
enabled: bool,
}
fn main() {
println!("🧪 Testing orion-conf with no format features enabled");
println!("This should demonstrate proper error handling...\n");
let config = TestConfig {
name: "no_feature_test".to_string(),
value: 42,
enabled: true,
};
let path = Path::new("no_feature_test.conf");
println!("=== Testing Save Operation ===");
match config.save_conf(path) {
Ok(_) => {
println!("❌ Unexpected success: save should have failed without features");
}
Err(e) => {
println!("✅ Expected error on save: {}", e);
if e.to_string().contains("no format feature enabled") {
println!("✅ Error message is correct");
} else {
println!("⚠️ Unexpected error message");
}
}
}
println!("\n=== Testing Load Operation ===");
match TestConfig::load_conf(path) {
Ok(_) => {
println!("❌ Unexpected success: load should have failed without features");
}
Err(e) => {
println!("✅ Expected error on load: {}", e);
if e.to_string().contains("no format feature enabled") {
println!("✅ Error message is correct");
} else {
println!("⚠️ Unexpected error message");
}
}
}
println!("\n🎉 No-feature error handling test completed!");
println!("✅ Library correctly prevents usage when no format features are enabled");
println!("✅ Users must explicitly enable at least one format feature");
}