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 9f5eb44 commit 8d79d25
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/site/src/feeds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn render_feeds(
} else {
&site.config.feed_filenames
};
println!("FF for {:?}: {:?}", lang, feed_filenames);

for feed_filename in feed_filenames {
let mut context = context.clone();

Expand Down
34 changes: 34 additions & 0 deletions components/site/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1373,4 +1373,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 8d79d25

Please sign in to comment.