Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Jan 8, 2025
1 parent a8a9e0b commit 0009a21
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion crates/rari-tools/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,58 @@ use serial_test::file_serial;
#[cfg(test)]
#[file_serial(file_fixtures)]
mod test {
use super::*;
use rari_types::locale::Locale;

use crate::tests::fixtures::docs::DocFixtures;

#[test]
fn test_do_move_dry_run() {
fn test_inventory() {
let expected = r#"[
{
"path": "/files/en-us/web/api/index.md",
"frontmatter": {
"title": "API",
"slug": "Web/API"
}
},
{
"path": "/files/en-us/web/api/exampleone/subexampletwo/index.md",
"frontmatter": {
"title": "SubExampleTwo",
"slug": "Web/API/ExampleOne/SubExampleTwo"
}
},
{
"path": "/files/en-us/web/api/exampleone/index.md",
"frontmatter": {
"title": "ExampleOne",
"slug": "Web/API/ExampleOne"
}
},
{
"path": "/files/en-us/web/api/exampleone/subexampleone/index.md",
"frontmatter": {
"title": "SubExampleOne",
"slug": "Web/API/ExampleOne/SubExampleOne"
}
},
{
"path": "/files/en-us/web/index.md",
"frontmatter": {
"title": "Web",
"slug": "Web"
}
}
]"#;
let slugs = vec![
"Web/API/ExampleOne".to_string(),
"Web/API/ExampleOne/SubExampleOne".to_string(),
"Web/API/ExampleOne/SubExampleTwo".to_string(),
];
let _docs = DocFixtures::new(&slugs, Locale::EnUs);
let inventory =
read_docs_parallel::<InventoryEntry, InventoryEntry>(&[content_root()], None).unwrap();
assert_eq!(expected, serde_json::to_string_pretty(&inventory).unwrap());
}
}

0 comments on commit 0009a21

Please sign in to comment.