()
| 22 | static TEST_MUX: LazyLock<Mutex<()>> = LazyLock::new(|| Mutex::new(())); |
| 23 | |
| 24 | pub async fn prepare<'a>() -> std::sync::MutexGuard<'a, ()> { |
| 25 | dotenv::dotenv().ok(); |
| 26 | dotenv::from_filename(".env.local").ok(); |
| 27 | |
| 28 | // Set a mutex lock to make sure database dependent tests are not overlapping. At the end of |
| 29 | // the function the guard is returned, so that the mutex guard can be kept during the lifetime |
| 30 | // of the function running the tests. |
| 31 | let guard = TEST_MUX.lock().unwrap(); |
| 32 | |
| 33 | // Set logger |
| 34 | TRACING_INIT.call_once(|| { |
| 35 | tracing_subscriber::fmt::init(); |
| 36 | }); |
| 37 | |
| 38 | // set test config |
| 39 | let mut conf: config::Configuration = Default::default(); |
| 40 | conf.postgresql.dsn = env::var("TEST_POSTGRESQL_DSN").unwrap(); |
| 41 | conf.redis.servers = vec![env::var("TEST_REDIS_URL").unwrap()]; |
| 42 | conf.sqlite.path = ":memory:".to_string(); |
| 43 | conf.network.enabled_regions = vec!["eu868".to_string()]; |
| 44 | conf.network.scheduler.class_b_schedule_advance = Duration::from_secs(128 * 2); |
| 45 | conf.regions = vec![config::Region { |
| 46 | id: "eu868".to_string(), |
| 47 | description: "EU868".to_string(), |
| 48 | common_name: lrwn::region::CommonName::EU868, |
| 49 | user_info: "".into(), |
| 50 | network: config::RegionNetwork { |
| 51 | installation_margin: 10.0, |
| 52 | rx1_delay: 1, |
| 53 | rx2_frequency: 869525000, |
| 54 | gateway_prefer_min_margin: 10.0, |
| 55 | downlink_tx_power: -1, |
| 56 | min_dr: 0, |
| 57 | max_dr: 5, |
| 58 | uplink_max_eirp: 16.0, |
| 59 | class_b: config::ClassB { |
| 60 | ping_slot_dr: 0, |
| 61 | ping_slot_frequency: 868100000, |
| 62 | }, |
| 63 | extra_channels: Vec::new(), |
| 64 | enabled_uplink_channels: Vec::new(), |
| 65 | ..Default::default() |
| 66 | }, |
| 67 | gateway: config::RegionGateway { |
| 68 | force_gws_private: false, |
| 69 | channels: vec![], |
| 70 | backend: config::GatewayBackend { |
| 71 | enabled: "mqtt".into(), |
| 72 | mqtt: config::GatewayBackendMqtt { |
| 73 | topic_prefix: "eu868".into(), |
| 74 | ..Default::default() |
| 75 | }, |
| 76 | }, |
| 77 | }, |
| 78 | }]; |
| 79 | config::set(conf); |
| 80 | |
| 81 | // setup storage |
no test coverage detected