use shanty_config::AppConfig; #[test] fn test_default_config() { let config = AppConfig::default(); assert_eq!(config.web.port, 8085); assert_eq!(config.web.bind, "0.0.0.0"); assert_eq!(config.tagging.confidence, 0.8); assert!(config.tagging.write_tags); assert!(!config.tagging.auto_tag); assert_eq!(config.download.format, "opus"); assert_eq!(config.download.search_source, "ytmusic"); assert_eq!(config.download.rate_limit, 250); assert_eq!(config.download.rate_limit_auth, 1800); assert_eq!(config.indexing.concurrency, 4); assert!(config.allowed_secondary_types.is_empty()); } #[test] fn test_load_missing_file() { // Loading from a nonexistent path should return defaults let config = AppConfig::load(Some("/tmp/shanty-test-nonexistent-config.yaml")); assert_eq!(config.web.port, 8085); } #[test] fn test_save_and_load_roundtrip() { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("config.yaml"); let path_str = path.to_string_lossy().to_string(); let mut config = AppConfig::default(); config.web.port = 9999; config.tagging.confidence = 0.95; config.download.format = "flac".to_string(); config.indexing.concurrency = 8; config.save(Some(&path_str)).unwrap(); let loaded = AppConfig::load(Some(&path_str)); assert_eq!(loaded.web.port, 9999); assert_eq!(loaded.tagging.confidence, 0.95); assert_eq!(loaded.download.format, "flac"); assert_eq!(loaded.indexing.concurrency, 8); } #[test] fn test_config_path_resolution() { let path = AppConfig::config_path(Some("/custom/path.yaml")); assert_eq!(path.to_string_lossy(), "/custom/path.yaml"); // Default path should end with config.yaml let default = AppConfig::config_path(None); assert!(default.to_string_lossy().ends_with("config.yaml")); }