diff --git a/swiftide/src/transformers/metadata_qa_code.rs b/swiftide/src/transformers/metadata_qa_code.rs index e7260f7a..5fd720e7 100644 --- a/swiftide/src/transformers/metadata_qa_code.rs +++ b/swiftide/src/transformers/metadata_qa_code.rs @@ -142,3 +142,29 @@ impl Transformer for MetadataQACode { self.concurrency } } + +#[cfg(test)] +mod test { + use crate::MockSimplePrompt; + + use super::*; + + #[tokio::test] + async fn test_metadata_qacode() { + let mut client = MockSimplePrompt::new(); + + client + .expect_prompt() + .returning(|_| Ok("Q1: Hello\nA1: World".to_string())); + + let transformer = MetadataQACode::builder().client(client).build().unwrap(); + let node = IngestionNode::new("Some text"); + + let result = transformer.transform_node(node).await.unwrap(); + + assert_eq!( + result.metadata.get("Questions and Answers").unwrap(), + "Q1: Hello\nA1: World" + ); + } +} diff --git a/swiftide/src/transformers/metadata_qa_text.rs b/swiftide/src/transformers/metadata_qa_text.rs index 8ee46fe1..b33caf91 100644 --- a/swiftide/src/transformers/metadata_qa_text.rs +++ b/swiftide/src/transformers/metadata_qa_text.rs @@ -143,3 +143,29 @@ impl Transformer for MetadataQAText { self.concurrency } } + +#[cfg(test)] +mod test { + use crate::MockSimplePrompt; + + use super::*; + + #[tokio::test] + async fn test_metadata_qacode() { + let mut client = MockSimplePrompt::new(); + + client + .expect_prompt() + .returning(|_| Ok("Q1: Hello\nA1: World".to_string())); + + let transformer = MetadataQAText::builder().client(client).build().unwrap(); + let node = IngestionNode::new("Some text"); + + let result = transformer.transform_node(node).await.unwrap(); + + assert_eq!( + result.metadata.get("Questions and Answers").unwrap(), + "Q1: Hello\nA1: World" + ); + } +}