From 0009a21e0b3f7daadc2cce86e925d70904d11c71 Mon Sep 17 00:00:00 2001 From: Florian Dieminger Date: Wed, 8 Jan 2025 19:50:19 +0100 Subject: [PATCH] add test --- crates/rari-tools/src/inventory.rs | 43 +++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/crates/rari-tools/src/inventory.rs b/crates/rari-tools/src/inventory.rs index d98ca58..2468896 100644 --- a/crates/rari-tools/src/inventory.rs +++ b/crates/rari-tools/src/inventory.rs @@ -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::(&[content_root()], None).unwrap(); + assert_eq!(expected, serde_json::to_string_pretty(&inventory).unwrap()); } }