fix: dont use mod db while migrating with tests-migrate
This commit is contained in:
parent
dfa83b1031
commit
f17e38c531
3 changed files with 13 additions and 14 deletions
|
@ -127,9 +127,9 @@ async fn download(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use super::Secret;
|
||||||
use crate::api::v1::get_random;
|
use crate::api::v1::get_random;
|
||||||
use crate::mcaptcha::PerformanceAnalytics;
|
use crate::mcaptcha::PerformanceAnalytics;
|
||||||
use super::Secret;
|
|
||||||
use crate::tests::*;
|
use crate::tests::*;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
@ -228,11 +228,12 @@ mod tests {
|
||||||
assert_eq!(resp.status(), StatusCode::CREATED);
|
assert_eq!(resp.status(), StatusCode::CREATED);
|
||||||
let job: super::UploadJobCreated = test::read_body_json(resp).await;
|
let job: super::UploadJobCreated = test::read_body_json(resp).await;
|
||||||
loop {
|
loop {
|
||||||
if data.get_job(&job.id).await.unwrap().unwrap().state
|
if let Some(job) = data.get_job(&job.id).await.unwrap() {
|
||||||
== *crate::db::JOB_STATE_FINISH
|
if job.state == *crate::db::JOB_STATE_FINISH {
|
||||||
{
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tokio::time::sleep(std::time::Duration::new(1, 0)).await;
|
tokio::time::sleep(std::time::Duration::new(1, 0)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ use std::env;
|
||||||
|
|
||||||
use sqlx::postgres::PgPoolOptions;
|
use sqlx::postgres::PgPoolOptions;
|
||||||
|
|
||||||
mod db;
|
|
||||||
mod settings;
|
mod settings;
|
||||||
|
|
||||||
pub use settings::Settings;
|
pub use settings::Settings;
|
||||||
|
@ -41,9 +40,7 @@ async fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
db::migrate_db(&db).await.unwrap();
|
sqlx::migrate!("./migrations/").run(&db).await.unwrap();
|
||||||
|
|
||||||
// sqlx::migrate!("./migrations/").run(&db).await.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build() {
|
fn build() {
|
||||||
|
|
11
src/tests.rs
11
src/tests.rs
|
@ -48,10 +48,9 @@ pub async fn get_test_data_with_mcaptcha_client(
|
||||||
settings.publish.dir = tmp_dir.join("base_path").to_str().unwrap().into();
|
settings.publish.dir = tmp_dir.join("base_path").to_str().unwrap().into();
|
||||||
settings.allow_registration = true;
|
settings.allow_registration = true;
|
||||||
let test_mcaptcha = crate::mcaptcha::tests::TestClient::default();
|
let test_mcaptcha = crate::mcaptcha::tests::TestClient::default();
|
||||||
(
|
let data = Data::new(settings, Box::new(test_mcaptcha.clone())).await;
|
||||||
Data::new(settings, Box::new(test_mcaptcha.clone())).await,
|
db::migrate_db(&data.db).await.unwrap();
|
||||||
test_mcaptcha,
|
(data, test_mcaptcha)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_test_data() -> Arc<Data> {
|
pub async fn get_test_data() -> Arc<Data> {
|
||||||
|
@ -60,7 +59,9 @@ pub async fn get_test_data() -> Arc<Data> {
|
||||||
settings.publish.dir = tmp_dir.join("base_path").to_str().unwrap().into();
|
settings.publish.dir = tmp_dir.join("base_path").to_str().unwrap().into();
|
||||||
settings.allow_registration = true;
|
settings.allow_registration = true;
|
||||||
let test_mcaptcha = Box::new(crate::mcaptcha::tests::TestClient::default());
|
let test_mcaptcha = Box::new(crate::mcaptcha::tests::TestClient::default());
|
||||||
Data::new(settings, test_mcaptcha).await
|
let data = Data::new(settings, test_mcaptcha).await;
|
||||||
|
db::migrate_db(&data.db).await.unwrap();
|
||||||
|
data
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
|
Loading…
Reference in a new issue