MCPcopy Create free account
hub / github.com/Botloader/botloader / main

Function main

cmd/prepare-integration-tests/src/main.rs:11–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10#[tokio::main]
11async fn main() -> Result<(), Box<dyn std::error::Error>> {
12 let config: RunConfig = common::load_config();
13 common::setup_tracing_stdout();
14
15 let guild_id = Id::from(config.guild_id);
16
17 info!("preparing scripts..");
18
19 let config_store = Db::new_with_url(&config.database_url).await?;
20 let premium_slot: stores::config::PremiumSlot = config_store
21 .create_update_premium_slot_by_source(CreateUpdatePremiumSlotBySource {
22 expires_at: chrono::Utc::now().add(chrono::Duration::days(100)),
23 manage_url: String::new(),
24 message: "testing".to_owned(),
25 source: "testing".to_owned(),
26 source_id: "testing".to_owned(),
27 title: "testing".to_owned(),
28 state: stores::config::PremiumSlotState::Active,
29 tier: stores::config::PremiumSlotTier::Premium,
30 user_id: Some(Id::new(1)),
31 })
32 .await
33 .unwrap();
34 config_store
35 .update_premium_slot_attachment(Id::new(1), premium_slot.id, Some(guild_id))
36 .await
37 .unwrap();
38
39 let compiled_filter_regex = config.filter.map(|v| regex::Regex::new(&v).unwrap());
40
41 let dir = std::fs::read_dir(config.scripts_path)?;
42 let entries = dir.collect::<Result<Vec<_>, _>>().unwrap();
43
44 for entry in &entries {
45 let os_name = entry.file_name();
46 let name_with_suffix = os_name.to_str().unwrap();
47 if !name_with_suffix.ends_with(".ts") || name_with_suffix.ends_with(".d.ts") {
48 continue;
49 }
50
51 if name_with_suffix != "lib.ts" {
52 if let Some(filter) = &compiled_filter_regex {
53 if !filter.is_match(name_with_suffix) {
54 info!("filtering active, skipped test {}", name_with_suffix);
55 continue;
56 }
57 }
58 }
59
60 let contents = std::fs::read_to_string(entry.path())?;
61
62 let name_without_suffix = name_with_suffix.strip_suffix(".ts").unwrap();
63 let added_script = config_store
64 .create_script(
65 guild_id,
66 CreateScript {
67 enabled: true,
68 name: name_without_suffix.to_string(),

Callers

nothing calls this directly

Calls 7

load_configFunction · 0.85
setup_tracing_stdoutFunction · 0.85
addMethod · 0.80
create_scriptMethod · 0.80
update_scriptMethod · 0.80

Tested by

no test coverage detected