Skip to content

Commit

Permalink
Execute client tests one at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
ksenia-vazhdaeva committed Jul 11, 2024
1 parent 6e1425c commit 2914d39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions media_gateway_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ rand = { workspace = true }
tokio = { workspace = true, features = ["test-util"] }

wiremock = "0.6.0"
once_cell = "1.19"
10 changes: 10 additions & 0 deletions media_gateway_client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,20 @@ impl TryFrom<&GatewayClientConfiguration> for GatewayClient {
#[cfg(test)]
mod tests {
use anyhow::anyhow;
use once_cell::sync::Lazy;
use rand::Rng;
use reqwest::{Client, StatusCode};
use savant_core::message::Message;
use tokio::sync::Mutex;
use wiremock::matchers::{body_bytes, method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};

use media_gateway_common::model::Media;

use crate::client::{ForwardResult, GatewayClient};

static TEST_EXECUTION: Lazy<Mutex<i32>> = Lazy::new(|| Mutex::new(0));

#[tokio::test]
async fn forward_message_success() {
forward_test(Some(StatusCode::OK), Ok(ForwardResult::Success)).await
Expand Down Expand Up @@ -186,6 +190,7 @@ mod tests {
http_status: Option<StatusCode>,
expected_result: anyhow::Result<ForwardResult>,
) {
let _ = TEST_EXECUTION.lock().await;
let message = Message::unknown("message".to_string());
let topic = "topic";
let data: Vec<&[u8]> = vec![&[1]];
Expand Down Expand Up @@ -215,6 +220,11 @@ mod tests {
)
};

println!(
"Expected status: {:?}, gateway URL: {}",
http_status, gateway_url
);

let client = GatewayClient::new(Client::default(), gateway_url);

let actual_result = client.forward_message(&media).await;
Expand Down

0 comments on commit 2914d39

Please sign in to comment.