MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / prepare

Function prepare

chirpstack/src/test/mod.rs:24–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22static TEST_MUX: LazyLock<Mutex<()>> = LazyLock::new(|| Mutex::new(()));
23
24pub 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

Callers 15

test_mqttFunction · 0.85
test_kafkaFunction · 0.85
test_redisFunction · 0.85
test_update_uplink_listFunction · 0.85
test_update_filter_listFunction · 0.85
test_update_relay_confFunction · 0.85
test_queue_itemFunction · 0.85

Calls 7

reset_dbFunction · 0.85
reset_redisFunction · 0.85
unwrapMethod · 0.80
to_stringMethod · 0.80
initFunction · 0.50
setFunction · 0.50
setupFunction · 0.50

Tested by

no test coverage detected