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

getdozer / dozer / 4020902227

pending completion
4020902227

Pull #743

github

GitHub
Merge 57279c6b6 into a12da35a5
Pull Request #743: Chore clippy fix

165 of 165 new or added lines in 60 files covered. (100.0%)

23638 of 35485 relevant lines covered (66.61%)

38417.79 hits per line

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

0.0
/dozer-ingestion/src/connectors/postgres/tests/client.rs
1
use crate::connectors::postgres::connection::helper::{connect, map_connection_config};
2
use dozer_types::models::connection::Authentication;
3
use dozer_types::rust_decimal::Decimal;
4
use postgres::Client;
5
use std::fmt::Write;
6

7
pub struct TestPostgresClient {
8
    client: Client,
9
    pub postgres_config: tokio_postgres::Config,
10
}
11

12
impl TestPostgresClient {
13
    pub fn new(auth: &Authentication) -> Self {
×
14
        let postgres_config = map_connection_config(auth).unwrap();
×
15

×
16
        let client = connect(postgres_config.clone()).unwrap();
×
17

×
18
        Self {
×
19
            client,
×
20
            postgres_config,
×
21
        }
×
22
    }
×
23

24
    pub fn execute_query(&mut self, query: &str) {
×
25
        self.client.query(query, &[]).unwrap();
×
26
    }
×
27

28
    pub fn create_simple_table(&mut self, schema: &str, table_name: &str) {
×
29
        self.execute_query(&format!(
×
30
            "CREATE TABLE {schema}.{table_name}
×
31
(
×
32
    id          SERIAL
×
33
        PRIMARY KEY,
×
34
    name        VARCHAR(255) NOT NULL,
×
35
    description VARCHAR(512),
×
36
    weight      DOUBLE PRECISION
×
37
);"
×
38
        ));
×
39
    }
×
40

×
41
    pub fn drop_schema(&mut self, schema: &str) {
×
42
        self.execute_query(&format!("DROP SCHEMA IF EXISTS {schema} CASCADE"));
×
43
    }
×
44

×
45
    pub fn drop_table(&mut self, schema: &str, table_name: &str) {
×
46
        self.execute_query(&format!("DROP TABLE IF EXISTS {schema}.{table_name}"));
×
47
    }
×
48

×
49
    pub fn create_schema(&mut self, schema: &str) {
×
50
        self.drop_schema(schema);
×
51
        self.execute_query(&format!("CREATE SCHEMA {schema}"));
×
52
    }
×
53

×
54
    pub fn insert_rows(&mut self, table_name: &str, count: u64) {
×
55
        let mut buf = String::new();
×
56
        for i in 0..count {
×
57
            if i > 0 {
×
58
                buf.write_str(",").unwrap();
×
59
            }
×
60
            buf.write_fmt(format_args!(
×
61
                "(\'Product {}\',\'Product {} description\',{})",
×
62
                i,
×
63
                i,
×
64
                Decimal::new((i * 41) as i64, 2)
×
65
            ))
×
66
            .unwrap();
×
67
        }
×
68

69
        let query = format!("insert into {table_name}(name, description, weight) values {buf}",);
×
70

×
71
        self.execute_query(&query);
×
72
    }
×
73
}
×
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

© 2025 Coveralls, Inc