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

getdozer / dozer / 4012757265

pending completion
4012757265

Pull #737

github

GitHub
Merge 41e5235a4 into c7b362bed
Pull Request #737: feat: select * wildcard

55 of 55 new or added lines in 4 files covered. (100.0%)

23308 of 35040 relevant lines covered (66.52%)

37782.56 hits per line

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

0.0
/dozer-admin/src/cli/utils.rs
1
use crate::db::{persistable::Persistable, pool::establish_connection};
2
use diesel_migrations::{EmbeddedMigrations, MigrationHarness};
3
use dotenvy::dotenv;
4
use dozer_orchestrator::internal_pipeline_service_client::InternalPipelineServiceClient;
5
use dozer_types::models::{api_config::ApiPipelineInternal, app_config::Config};
6
use std::{env, error::Error, fs, process::Command};
7
use tonic::transport::Channel;
8

9
pub async fn init_internal_pipeline_client(
×
10
    config: ApiPipelineInternal,
×
11
) -> Result<InternalPipelineServiceClient<Channel>, Box<dyn std::error::Error>> {
×
12
    let address = format!("http://{:}:{:}", config.host, config.port);
×
13
    let client = dozer_orchestrator::internal_pipeline_service_client::InternalPipelineServiceClient::connect(address).await?;
×
14
    Ok(client)
×
15
}
×
16

17
type DB = diesel::sqlite::Sqlite;
18
const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");
19
fn run_migrations(
20
    connection: &mut impl MigrationHarness<DB>,
21
) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
22
    connection.revert_all_migrations(MIGRATIONS)?;
×
23
    connection.run_pending_migrations(MIGRATIONS)?;
×
24
    Ok(())
×
25
}
×
26
pub fn get_db_path() -> String {
×
27
    env::var("DATABASE_URL").unwrap_or_else(|_| "dozer.db".to_owned())
×
28
}
×
29
pub fn reset_db() {
×
30
    dotenv().ok();
×
31
    let database_url = get_db_path();
×
32
    // check if db file exist
×
33
    let db_file_exist = std::path::Path::new(&database_url).exists();
×
34
    if db_file_exist {
×
35
        fs::remove_file(&database_url).unwrap();
×
36
    }
×
37
    // create new db
38
    let db_pool = establish_connection(database_url);
×
39
    let mut db_connection = db_pool.get().unwrap();
×
40
    // run migration
×
41
    run_migrations(&mut db_connection).unwrap();
×
42
}
×
43

44
pub fn init_db_with_config(mut config: Config) -> Config {
×
45
    let database_url = get_db_path();
×
46
    let db_pool = establish_connection(database_url);
×
47
    config.save(db_pool).unwrap();
×
48
    config
×
49
}
×
50

51
pub fn kill_process_at(port: u16) {
×
52
    let mut check_ports_used = Command::new("lsof");
×
53
    check_ports_used.args(["-t", &format!("-i:{:}", port)]);
×
54
    let check_port_result = check_ports_used
×
55
        .output()
×
56
        .expect("failed to execute process");
×
57
    let check_port_result_str = String::from_utf8(check_port_result.stdout).unwrap();
×
58
    if !check_port_result_str.is_empty() {
×
59
        let ports: Vec<String> = check_port_result_str
×
60
            .split('\n')
×
61
            .into_iter()
×
62
            .map(|s| s.to_string())
×
63
            .filter(|s| !s.is_empty())
×
64
            .collect();
×
65
        let _clear_grpc_port_command = Command::new("kill")
×
66
            .args(["-9", &ports[ports.len() - 1]])
×
67
            .output()
×
68
            .unwrap();
×
69
    }
×
70
}
×
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