feat: gate feed/sitemap generation on config
Wire config.feed.enabled and config.sitemap.enabled into main.rs run() function. Both default to true, so existing behavior is preserved. Add 5 new tests: feed/sitemap config defaults, independent disable, and ConfigContext nav structure with base_url trailing-slash normalization. Test suite: 69 → 73 tests, all passing. Phase 1 complete — all plan items checked off.
This commit is contained in:
@@ -161,4 +161,52 @@ mod tests {
|
||||
assert_eq!(config.paths.static_dir, PathBuf::from("assets"));
|
||||
assert_eq!(config.paths.templates, PathBuf::from("theme"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_feed_sitemap_defaults() {
|
||||
let toml = r#"
|
||||
title = "Test"
|
||||
author = "Author"
|
||||
base_url = "https://example.com"
|
||||
"#;
|
||||
|
||||
let config: SiteConfig = toml::from_str(toml).unwrap();
|
||||
assert!(config.feed.enabled, "feed should be enabled by default");
|
||||
assert!(
|
||||
config.sitemap.enabled,
|
||||
"sitemap should be enabled by default"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_feed_disabled() {
|
||||
let toml = r#"
|
||||
title = "Test"
|
||||
author = "Author"
|
||||
base_url = "https://example.com"
|
||||
|
||||
[feed]
|
||||
enabled = false
|
||||
"#;
|
||||
|
||||
let config: SiteConfig = toml::from_str(toml).unwrap();
|
||||
assert!(!config.feed.enabled);
|
||||
assert!(config.sitemap.enabled, "sitemap unaffected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sitemap_disabled() {
|
||||
let toml = r#"
|
||||
title = "Test"
|
||||
author = "Author"
|
||||
base_url = "https://example.com"
|
||||
|
||||
[sitemap]
|
||||
enabled = false
|
||||
"#;
|
||||
|
||||
let config: SiteConfig = toml::from_str(toml).unwrap();
|
||||
assert!(config.feed.enabled, "feed unaffected");
|
||||
assert!(!config.sitemap.enabled);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user