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

supabase / etl / 24713061833

21 Apr 2026 08:47AM UTC coverage: 78.316% (+0.07%) from 78.248%
24713061833

push

github

web-flow
refactor: enable extended clippy lint set (#675)

* refactor: explicit_iter_loop

* refactor: implicit_clone

* refactor: manual_let_else

* refactor: map_unwrap_or

* refactor: match_same_arms

* refactor: clippy::redundant_closure_for_method_calls

* refactor: redundant_clone

* refactor: redundant_test_prefix

* refactor: semicolon_if_nothing_returned

* refactor: uninlined_format_args

* refactor: unnested_or_patterns

* feat: enable extra lints

* fix: rebase

* fix: removed test

* fix: after rebase

* fix: fmt

* fix: http tests

* fix: rebase

* fix: fmt

* fix: fmt

414 of 503 new or added lines in 59 files covered. (82.31%)

3292 existing lines in 120 files now uncovered.

24379 of 31129 relevant lines covered (78.32%)

1069.73 hits per line

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

77.14
/etl-postgres/src/sqlx/test_utils.rs
1
use etl_config::shared::{IntoConnectOptions, PgConnectionConfig};
2
use sqlx::{Connection, Executor, PgConnection, PgPool};
3

4
/// Creates a new Postgres database and returns a connection pool.
5
///
6
/// Connects to Postgres server, creates a new database, and returns a
7
/// [`PgPool`] connected to the newly created database.
8
///
9
/// # Panics
10
/// Panics if connection or database creation fails.
11
pub async fn create_pg_database(config: &PgConnectionConfig) -> PgPool {
152✔
12
    // Create the database via a single connection.
13
    let mut connection = PgConnection::connect_with(&config.without_db(None))
152✔
14
        .await
152✔
15
        .expect("Failed to connect to Postgres");
152✔
16
    connection
152✔
17
        .execute(&*format!(r#"create database "{}";"#, config.name))
152✔
18
        .await
152✔
19
        .expect("Failed to create database");
152✔
20

21
    // Create a connection pool to the database.
22
    PgPool::connect_with(config.with_db(None)).await.expect("Failed to connect to Postgres")
152✔
23
}
152✔
24

25
/// Drops a Postgres database and terminates all connections.
26
///
27
/// Connects to Postgres server, forcefully terminates active connections
28
/// to the target database, and drops it if it exists. Used for test cleanup.
29
///
30
/// This function will not panic on errors - it logs them and continues.
31
/// This ensures test cleanup doesn't fail when databases are already gone
32
/// or connections can't be established.
33
pub async fn drop_pg_database(config: &PgConnectionConfig) {
152✔
34
    // Connect to the default database.
35
    let mut connection = match PgConnection::connect_with(&config.without_db(None)).await {
152✔
36
        Ok(conn) => conn,
152✔
UNCOV
37
        Err(e) => {
×
UNCOV
38
            eprintln!("warning: failed to connect to Postgres for cleanup: {e}");
×
39
            return;
×
40
        }
41
    };
42

43
    // Forcefully terminate any remaining connections to the database.
44
    if let Err(e) = connection
152✔
45
        .execute(&*format!(
152✔
46
            r#"
152✔
47
            select pg_terminate_backend(pg_stat_activity.pid)
152✔
48
            from pg_stat_activity
152✔
49
            where pg_stat_activity.datname = '{}'
152✔
50
            and pid <> pg_backend_pid();"#,
152✔
51
            config.name
152✔
52
        ))
152✔
53
        .await
152✔
UNCOV
54
    {
×
UNCOV
55
        eprintln!("warning: failed to terminate connections for database {}: {}", config.name, e);
×
56
    }
152✔
57

58
    // Drop the database.
59
    if let Err(e) =
×
60
        connection.execute(&*format!(r#"drop database if exists "{}";"#, config.name)).await
152✔
UNCOV
61
    {
×
UNCOV
62
        eprintln!("warning: failed to drop database {}: {}", config.name, e);
×
63
    }
152✔
64
}
152✔
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