Skip to content

Commit

Permalink
Update tests to use mocktail 0.1.2-alpha
Browse files Browse the repository at this point in the history
Signed-off-by: Mateus Devino <mdevino@ibm.com>
  • Loading branch information
mdevino committed Feb 28, 2025
1 parent 84c431c commit c5fddc4
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/text_content_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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![
Expand All @@ -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,
Expand All @@ -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?;

Expand Down Expand Up @@ -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()],
Expand Down Expand Up @@ -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()],
Expand Down Expand Up @@ -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()],
Expand Down Expand Up @@ -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()],
Expand Down Expand Up @@ -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(),
Expand All @@ -632,15 +632,15 @@ 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(),
find_available_port().unwrap(),
None,
None,
None,
Some(vec![(chunker_id.into(), mock_chunker_server)]),
Some(vec![mock_chunker_server]),
)
.await?;

Expand Down

0 comments on commit c5fddc4

Please sign in to comment.