Skip to content

Commit

Permalink
Remove debugging print. Add test for generate_feeds defined in both g…
Browse files Browse the repository at this point in the history
…lobal and default language block. Currently set to prefer the language level config.
  • Loading branch information
SumDonkuS committed Jul 2, 2024
1 parent 096a72f commit 441df7e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions components/site/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,4 +1367,38 @@ feed_filenames = ["rss.xml"]
assert!(!std::fs::read_to_string(public_dir.join("fr").join("rss.xml")).unwrap().contains("My En Article"));
assert!(std::fs::read_to_string(public_dir.join("fr").join("rss.xml")).unwrap().contains("My Fr Article"));
}

#[test]
fn can_render_feed_for_multi_language_with_language_level_feed_flag_preferred_for_default() {
let config_raw = r#"
base_url = "https://replace-this-with-your-url.com"
default_language = "en"
generate_feeds = false
[languages.en]
title = "My English site"
generate_feeds = true
[languages.fr]
title = "My French site"
generate_feeds = true
"#;
let pages = vec![
("My En Article", "content/my-article.md", "en"),
("My Fr Article", "content/my-article.fr.md", "fr"),
];

let (tmp_dir, site) = create_site_from_config_and_pages(config_raw, &pages);
let public_dir = site.output_path;

assert!(tmp_dir.path().exists());
assert!(public_dir.exists());
assert!(public_dir.join("atom.xml").exists());
assert!(public_dir.join("fr").join("atom.xml").exists());
assert!(std::fs::read_to_string(public_dir.join("atom.xml")).unwrap().contains("My En Article"));
assert!(!std::fs::read_to_string(public_dir.join("atom.xml")).unwrap().contains("My Fr Article"));
assert!(!std::fs::read_to_string(public_dir.join("fr").join("atom.xml")).unwrap().contains("My En Article"));
assert!(std::fs::read_to_string(public_dir.join("fr").join("atom.xml")).unwrap().contains("My Fr Article"));
}
}

0 comments on commit 441df7e

Please sign in to comment.