From 9d86069e8fa1167c55336b5b7fa46c94684440d5 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Sun, 6 Jun 2021 13:27:17 +0300 Subject: [PATCH] chore: add dev deps for tests --- migra_cli/Cargo.toml | 11 ++++--- migra_cli/src/database/migration.rs | 2 +- migra_cli/src/database/transaction.rs | 2 +- migra_cli/tests/commands.rs | 43 +++++++++------------------ 4 files changed, 23 insertions(+), 35 deletions(-) diff --git a/migra_cli/Cargo.toml b/migra_cli/Cargo.toml index 932f81e..5c0dfbe 100644 --- a/migra_cli/Cargo.toml +++ b/migra_cli/Cargo.toml @@ -28,6 +28,13 @@ toml = "0.5" chrono = "0.4" dotenv = { version = "0.15", optional = true } +[dev-dependencies] +assert_cmd = "1" +predicates = "1" +client_postgres = { package = "postgres", version = "0.19" } +client_mysql = { package = "mysql", version = "20.1" } +client_rusqlite = { package = "rusqlite", version = "0.25" } + [badges] maintenance = { status = "actively-developed" } @@ -38,7 +45,3 @@ path = "src/main.rs" [[test]] name = "integration" path = "tests/commands.rs" - -[dev-dependencies] -assert_cmd = "1" -predicates = "1" diff --git a/migra_cli/src/database/migration.rs b/migra_cli/src/database/migration.rs index 1498b99..048b585 100644 --- a/migra_cli/src/database/migration.rs +++ b/migra_cli/src/database/migration.rs @@ -1,4 +1,4 @@ -use super::connection::AnyConnection; +use super::client_rusqlite::Connection::AnyConnection; use crate::Config; use crate::StdResult; use std::fs; diff --git a/migra_cli/src/database/transaction.rs b/migra_cli/src/database/transaction.rs index 3a6e507..ffc38b0 100644 --- a/migra_cli/src/database/transaction.rs +++ b/migra_cli/src/database/transaction.rs @@ -1,4 +1,4 @@ -use super::connection::AnyConnection; +use super::client_rusqlite::Connection::AnyConnection; use crate::error::StdResult; pub trait ManageTransaction { diff --git a/migra_cli/tests/commands.rs b/migra_cli/tests/commands.rs index d43dcef..ea5ed75 100644 --- a/migra_cli/tests/commands.rs +++ b/migra_cli/tests/commands.rs @@ -1,5 +1,6 @@ pub use assert_cmd::prelude::*; pub use cfg_if::cfg_if; +use client_mysql::prelude::*; pub use predicates::str::contains; pub use std::process::Command; @@ -444,7 +445,7 @@ mod upgrade { #[cfg(feature = "postgres")] inner("postgres", || { - let mut conn = postgres::Client::connect(POSTGRES_URL, postgres::NoTls)?; + let mut conn = client_postgres::Client::connect(POSTGRES_URL, client_postgres::NoTls)?; let res = conn.query("SELECT p.id, a.id FROM persons AS p, articles AS a", &[])?; assert_eq!( @@ -459,9 +460,7 @@ mod upgrade { #[cfg(feature = "mysql")] inner("mysql", || { - use mysql::prelude::*; - - let pool = mysql::Pool::new(MYSQL_URL)?; + let pool = client_mysql::Pool::new(MYSQL_URL)?; let mut conn = pool.get_conn()?; let res = conn.query_drop("SELECT p.id, a.id FROM persons AS p, articles AS a")?; @@ -474,9 +473,7 @@ mod upgrade { #[cfg(feature = "sqlite")] remove_sqlite_db().and_then(|_| { inner("sqlite", || { - use rusqlite::Connection; - - let conn = Connection::open(SQLITE_URL)?; + let conn = client_rusqlite::Connection::open(SQLITE_URL)?; let res = conn.execute_batch("SELECT p.id, a.id FROM persons AS p, articles AS a")?; assert_eq!(res, ()); @@ -517,7 +514,7 @@ mod upgrade { #[cfg(feature = "postgres")] inner("postgres_invalid", || { - let mut conn = postgres::Client::connect(POSTGRES_URL, postgres::NoTls)?; + let mut conn = client_postgres::Client::connect(POSTGRES_URL, client_postgres::NoTls)?; let articles_res = conn.query("SELECT a.id FROM articles AS a", &[]); let persons_res = conn.query("SELECT p.id FROM persons AS p", &[]); @@ -530,9 +527,7 @@ mod upgrade { #[cfg(feature = "sqlite")] remove_sqlite_db().and_then(|_| { inner("sqlite_invalid", || { - use rusqlite::Connection; - - let conn = Connection::open(SQLITE_URL)?; + let conn = client_rusqlite::Connection::open(SQLITE_URL)?; let articles_res = conn.execute_batch("SELECT a.id FROM articles AS a"); let persons_res = conn.execute_batch("SELECT p.id FROM persons AS p"); @@ -569,7 +564,7 @@ mod upgrade { #[cfg(feature = "postgres")] inner("postgres_invalid", || { - let mut conn = postgres::Client::connect(POSTGRES_URL, postgres::NoTls)?; + let mut conn = client_postgres::Client::connect(POSTGRES_URL, client_postgres::NoTls)?; let articles_res = conn.query("SELECT a.id FROM articles AS a", &[]); let persons_res = conn.query("SELECT p.id FROM persons AS p", &[]); @@ -582,9 +577,7 @@ mod upgrade { #[cfg(feature = "sqlite")] remove_sqlite_db().and_then(|_| { inner("sqlite_invalid", || { - use rusqlite::Connection; - - let conn = Connection::open(SQLITE_URL)?; + let conn = client_rusqlite::Connection::open(SQLITE_URL)?; let articles_res = conn.execute_batch("SELECT a.id FROM articles AS a"); let persons_res = conn.execute_batch("SELECT p.id FROM persons AS p"); @@ -636,7 +629,7 @@ mod apply { "migrations/210218233414_create_persons/up", ], || { - let mut conn = postgres::Client::connect(POSTGRES_URL, postgres::NoTls)?; + let mut conn = client_postgres::Client::connect(POSTGRES_URL, client_postgres::NoTls)?; let res = conn.query("SELECT p.id, a.id FROM persons AS p, articles AS a", &[])?; assert_eq!( @@ -657,7 +650,7 @@ mod apply { "migrations/210218232851_create_articles/down", ], || { - let mut conn = postgres::Client::connect(POSTGRES_URL, postgres::NoTls)?; + let mut conn = client_postgres::Client::connect(POSTGRES_URL, client_postgres::NoTls)?; let res = conn.query("SELECT p.id, a.id FROM persons AS p, articles AS a", &[]); assert!(res.is_err()); @@ -677,9 +670,7 @@ mod apply { "migrations/210218233414_create_persons/up", ], || { - use mysql::prelude::*; - - let pool = mysql::Pool::new(MYSQL_URL)?; + let pool = client_mysql::Pool::new(MYSQL_URL)?; let mut conn = pool.get_conn()?; let res = conn.query_drop("SELECT p.id, a.id FROM persons AS p, articles AS a")?; @@ -697,9 +688,7 @@ mod apply { "migrations/210218232851_create_articles/down", ], || { - use mysql::prelude::*; - - let pool = mysql::Pool::new(MYSQL_URL)?; + let pool = client_mysql::Pool::new(MYSQL_URL)?; let mut conn = pool.get_conn()?; let res = conn.query_drop("SELECT p.id, a.id FROM persons AS p, articles AS a"); @@ -721,9 +710,7 @@ mod apply { "migrations/210218233414_create_persons/up", ], || { - use rusqlite::Connection; - - let conn = Connection::open(SQLITE_URL)?; + let conn = client_rusqlite::Connection::open(SQLITE_URL)?; let res = conn.execute_batch("SELECT p.id, a.id FROM persons AS p, articles AS a")?; assert_eq!(res, ()); @@ -739,9 +726,7 @@ mod apply { "migrations/210218232851_create_articles/down", ], || { - use rusqlite::Connection; - - let conn = Connection::open(SQLITE_URL)?; + let conn = client_rusqlite::Connection::open(SQLITE_URL)?; let res = conn.execute_batch("SELECT p.id, a.id FROM persons AS p, articles AS a"); assert!(res.is_err());