From c5fddc47d450698df085475f2d85dbfc3d5fac80 Mon Sep 17 00:00:00 2001 From: Mateus Devino Date: Fri, 28 Feb 2025 10:23:56 -0300 Subject: [PATCH] Update tests to use mocktail 0.1.2-alpha Signed-off-by: Mateus Devino --- tests/text_content_detection.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/text_content_detection.rs b/tests/text_content_detection.rs index 1f093ad1..2f87ac22 100644 --- a/tests/text_content_detection.rs +++ b/tests/text_content_detection.rs @@ -55,7 +55,7 @@ async fn test_no_detection_whole_doc() -> Result<(), anyhow::Error> { // Add detector mock let mut mocks = MockSet::new(); mocks.insert( - MockPath::new(Method::POST, TEXT_CONTENTS_DETECTOR_ENDPOINT), + MockPath::post(TEXT_CONTENTS_DETECTOR_ENDPOINT), Mock::new( MockRequest::json(ContentAnalysisRequest { contents: vec!["This sentence has no detections.".into()], @@ -109,7 +109,7 @@ async fn test_no_detection_sentence_chunker() -> Result<(), anyhow::Error> { let mut chunker_mocks = MockSet::new(); chunker_mocks.insert( - MockPath::new(Method::POST, CHUNKER_UNARY_ENDPOINT), + MockPath::post(CHUNKER_UNARY_ENDPOINT), Mock::new( MockRequest::pb(ChunkerTokenizationTaskRequest { text: "This sentence does not have a detection. Neither does this one.".into(), @@ -137,7 +137,7 @@ async fn test_no_detection_sentence_chunker() -> Result<(), anyhow::Error> { let detector_name = DETECTOR_NAME_ANGLE_BRACKETS_SENTENCE; let mut mocks = MockSet::new(); mocks.insert( - MockPath::new(Method::POST, TEXT_CONTENTS_DETECTOR_ENDPOINT), + MockPath::post(TEXT_CONTENTS_DETECTOR_ENDPOINT), Mock::new( MockRequest::json(ContentAnalysisRequest { contents: vec![ @@ -154,7 +154,7 @@ async fn test_no_detection_sentence_chunker() -> Result<(), anyhow::Error> { ); // Start orchestrator server and its dependencies - let mock_chunker_server = MockChunkersServiceServer::new(chunker_mocks)?; + let mock_chunker_server = GrpcMockServer::new(chunker_id, chunker_mocks)?; let mock_detector_server = HttpMockServer::new(detector_name, mocks)?; let orchestrator_server = TestOrchestratorServer::run( ORCHESTRATOR_CONFIG_FILE_PATH, @@ -163,7 +163,7 @@ async fn test_no_detection_sentence_chunker() -> Result<(), anyhow::Error> { None, None, Some(vec![mock_detector_server]), - Some(vec![(chunker_id.into(), mock_chunker_server)]), + Some(vec![mock_chunker_server]), ) .await?; @@ -386,7 +386,7 @@ async fn test_detector_returns_503() -> Result<(), anyhow::Error> { // Add input detection mock let mut detection_mocks = MockSet::new(); detection_mocks.insert( - MockPath::new(Method::POST, TEXT_CONTENTS_DETECTOR_ENDPOINT), + MockPath::post(TEXT_CONTENTS_DETECTOR_ENDPOINT), Mock::new( MockRequest::json(ContentAnalysisRequest { contents: vec!["This should return a 503".into()], @@ -448,7 +448,7 @@ async fn test_detector_returns_404() -> Result<(), anyhow::Error> { // Add input detection mock let mut detection_mocks = MockSet::new(); detection_mocks.insert( - MockPath::new(Method::POST, TEXT_CONTENTS_DETECTOR_ENDPOINT), + MockPath::post(TEXT_CONTENTS_DETECTOR_ENDPOINT), Mock::new( MockRequest::json(ContentAnalysisRequest { contents: vec!["This should return a 404".into()], @@ -510,7 +510,7 @@ async fn test_detector_returns_500() -> Result<(), anyhow::Error> { // Add input detection mock let mut detection_mocks = MockSet::new(); detection_mocks.insert( - MockPath::new(Method::POST, TEXT_CONTENTS_DETECTOR_ENDPOINT), + MockPath::post(TEXT_CONTENTS_DETECTOR_ENDPOINT), Mock::new( MockRequest::json(ContentAnalysisRequest { contents: vec!["This should return a 500".into()], @@ -563,7 +563,7 @@ async fn test_detector_returns_non_compliant_message() -> Result<(), anyhow::Err // Add input detection mock let mut detection_mocks = MockSet::new(); detection_mocks.insert( - MockPath::new(Method::POST, TEXT_CONTENTS_DETECTOR_ENDPOINT), + MockPath::post(TEXT_CONTENTS_DETECTOR_ENDPOINT), Mock::new( MockRequest::json(ContentAnalysisRequest { contents: vec!["This should return a non-compliant message".into()], @@ -621,7 +621,7 @@ async fn test_chunker_returns_an_error() -> Result<(), anyhow::Error> { let mut chunker_mocks = MockSet::new(); chunker_mocks.insert( - MockPath::new(Method::POST, CHUNKER_UNARY_ENDPOINT), + MockPath::post(CHUNKER_UNARY_ENDPOINT), Mock::new( MockRequest::pb(ChunkerTokenizationTaskRequest { text: "This should return a 500".into(), @@ -632,7 +632,7 @@ async fn test_chunker_returns_an_error() -> Result<(), anyhow::Error> { ); // Start orchestrator server and its dependencies - let mock_chunker_server = MockChunkersServiceServer::new(chunker_mocks)?; + let mock_chunker_server = GrpcMockServer::new(chunker_id, chunker_mocks)?; let orchestrator_server = TestOrchestratorServer::run( ORCHESTRATOR_CONFIG_FILE_PATH, find_available_port().unwrap(), @@ -640,7 +640,7 @@ async fn test_chunker_returns_an_error() -> Result<(), anyhow::Error> { None, None, None, - Some(vec![(chunker_id.into(), mock_chunker_server)]), + Some(vec![mock_chunker_server]), ) .await?;