• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / pg_replicate / 15161550595

21 May 2025 11:58AM UTC coverage: 54.221% (+13.6%) from 40.572%
15161550595

Pull #121

github

web-flow
Merge 12faaeca6 into be326a515
Pull Request #121: feat(tests): Add integration tests for pg_replicate

318 of 422 new or added lines in 14 files covered. (75.36%)

99 existing lines in 3 files now uncovered.

3494 of 6444 relevant lines covered (54.22%)

26.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/api/src/main.rs
1
use std::env;
2

3
use anyhow::anyhow;
4
use api::{
5
    configuration::{get_settings, Settings},
6
    startup::Application,
7
};
8
use postgres::sqlx::options::PgDatabaseOptions;
9
use telemetry::init_tracing;
10
use tracing::{error, info};
11

12
#[actix_web::main]
13
pub async fn main() -> anyhow::Result<()> {
14
    let app_name = env!("CARGO_BIN_NAME");
15
    // We pass emit_on_span_close = true to emit logs on span close
16
    // for the api because it is a web server and we need to emit logs
17
    // for every closing request. This is a bit of a hack, but it works
18
    // for now. Ideally the tracing middleware should emit a log on
19
    // request end, but it doesn't do that yet.
20
    let _log_flusher = init_tracing(app_name, true)?;
21
    let mut args = env::args();
22

23
    match args.len() {
24
        // Run the application server
25
        1 => {
26
            let configuration = get_settings::<'_, Settings>()?;
27
            log_pg_database_options(&configuration.database);
28
            let application = Application::build(configuration.clone()).await?;
29
            application.run_until_stopped().await?;
30
        }
31
        // Handle single command commands
32
        2 => {
33
            let command = args.nth(1).unwrap();
34
            match command.as_str() {
35
                "migrate" => {
36
                    let options = get_settings::<'_, PgDatabaseOptions>()?;
37
                    log_pg_database_options(&options);
38
                    Application::migrate_database(options).await?;
39
                    info!("database migrated successfully");
40
                }
41
                _ => {
42
                    let message = format!("invalid command: {command}");
43
                    error!("{message}");
44
                    return Err(anyhow!(message));
45
                }
46
            }
47
        }
48
        _ => {
49
            let message = "invalid number of command line arguments";
50
            error!("{message}");
51
            return Err(anyhow!(message));
52
        }
53
    }
54

55
    Ok(())
56
}
57

NEW
58
fn log_pg_database_options(options: &PgDatabaseOptions) {
×
59
    info!(
×
60
        host = options.host,
61
        port = options.port,
62
        dbname = options.name,
63
        username = options.username,
64
        require_ssl = options.require_ssl,
NEW
65
        "pg database options",
×
66
    );
67
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc