Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yin1999 committed Feb 12, 2025
1 parent 59f7b01 commit 678d676
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion crates/rari-tools/src/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ mod test {
fn test_remove_single() {
let slugs = vec!["Web/API/ExampleOne".to_string()];
let _docs = DocFixtures::new(&slugs, Locale::EnUs);
// The redirects file is needed to attempt removing the redirects
let _redirects = RedirectFixtures::new(&[], Locale::EnUs);
let _wikihistory = WikihistoryFixtures::new(&slugs, Locale::EnUs);
let _sidebars = SidebarFixtures::default();

Expand All @@ -413,7 +415,32 @@ mod test {
}

#[test]
fn test_remove_single_with_redirect() {
fn test_remove_single_and_redirect() {
let slugs = vec!["Web/API/ExampleOne".to_string()];
let redirects = vec![("Web/API/OldExampleOne".to_string(), "Web/API/ExampleOne".to_string())];
let _docs = DocFixtures::new(&slugs, Locale::EnUs);
let _redirects = RedirectFixtures::new(&redirects, Locale::EnUs);
let _wikihistory = WikihistoryFixtures::new(&slugs, Locale::EnUs);
let _sidebars = SidebarFixtures::default();

let result = do_remove("Web/API/ExampleOne", Locale::EnUs, false, None, false);
assert!(result.is_ok());

let should_exist = vec![];
let should_not_exist = vec!["en-us/web/api/exampleone/index.md"];
let root_path = root_for_locale(Locale::EnUs).unwrap();
check_file_existence(root_path, &should_exist, &should_not_exist);

let redirects = get_redirects_map(Locale::EnUs);
assert!(!redirects.contains_key("Web/API/OldExampleOne"));
assert!(!redirects.contains_key("Web/API/exampleone"));

let wiki_history = test_get_wiki_history(Locale::EnUs);
assert!(!wiki_history.contains_key("Web/API/ExampleOne"));
}

#[test]
fn test_remove_single_with_redirect_target() {
let slugs = vec![
"Web/API/ExampleOne".to_string(),
"Web/API/RedirectTarget".to_string(),
Expand Down

0 comments on commit 678d676

Please sign in to comment.