Skip to content

Commit

Permalink
fix database test, and write test to check config init multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
AryanGodara authored and Tranduy1dol committed Aug 1, 2024
1 parent da8296e commit 32be758
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions crates/orchestrator/tests/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
use std::collections::HashMap;

use super::common::get_or_init_config;
use super::common::{
get_or_init_config,
constants::{
DA_LAYER, MADARA_RPC_URL, MONGODB_CONNECTION_STRING,
}
};

use orchestrator::config::Config;
use orchestrator::jobs::types::{
Expand Down Expand Up @@ -32,6 +37,28 @@ async fn test_valid_config(
config.queue();
}

#[rstest]
#[case::pass(
String::from(MADARA_RPC_URL),
String::from(MONGODB_CONNECTION_STRING),
String::from(DA_LAYER),
)]
#[case::pass(
String::from("http://invalid::invalid"), // No new config gets created
String::from(MONGODB_CONNECTION_STRING),
String::from(DA_LAYER),
)]
#[tokio::test]
async fn test_init_config_runs_ony_once(
#[case] rpc_url: String, #[case] db_url: String, #[case] da_url: String
) {
let config = get_or_init_config(rpc_url, db_url, da_url).await;
config.starknet_client();
config.da_client();
config.database();
config.queue();
}

#[ignore = "Run this separately as it will fail the other tests (config can't be created with each test)"]
#[rstest(get_or_init_config(String::from("http://invalid:invalid")))]
#[should_panic]
Expand Down Expand Up @@ -66,7 +93,6 @@ async fn test_config_da_client(
}

#[rstest]
#[should_panic]
#[tokio::test]
async fn test_config_database(
#[future] get_or_init_config: &Config,
Expand Down

0 comments on commit 32be758

Please sign in to comment.