fix: dont use mod db while migrating with tests-migrate
Some checks failed
ci/woodpecker/push/woodpecker Pipeline is pending
ci/woodpecker/pr/woodpecker Pipeline failed

This commit is contained in:
Aravinth Manivannan 2023-10-20 02:38:14 +05:30
parent dfa83b1031
commit f17e38c531
Signed by: realaravinth
GPG key ID: F8F50389936984FF
3 changed files with 13 additions and 14 deletions

View file

@ -127,9 +127,9 @@ async fn download(
#[cfg(test)]
mod tests {
use super::Secret;
use crate::api::v1::get_random;
use crate::mcaptcha::PerformanceAnalytics;
use super::Secret;
use crate::tests::*;
use crate::*;
@ -228,11 +228,12 @@ mod tests {
assert_eq!(resp.status(), StatusCode::CREATED);
let job: super::UploadJobCreated = test::read_body_json(resp).await;
loop {
if data.get_job(&job.id).await.unwrap().unwrap().state
== *crate::db::JOB_STATE_FINISH
{
break;
if let Some(job) = data.get_job(&job.id).await.unwrap() {
if job.state == *crate::db::JOB_STATE_FINISH {
break;
}
}
tokio::time::sleep(std::time::Duration::new(1, 0)).await;
}

View file

@ -18,7 +18,6 @@ use std::env;
use sqlx::postgres::PgPoolOptions;
mod db;
mod 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() {

View file

@ -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.allow_registration = true;
let test_mcaptcha = crate::mcaptcha::tests::TestClient::default();
(
Data::new(settings, Box::new(test_mcaptcha.clone())).await,
test_mcaptcha,
)
let data = Data::new(settings, Box::new(test_mcaptcha.clone())).await;
db::migrate_db(&data.db).await.unwrap();
(data, test_mcaptcha)
}
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.allow_registration = true;
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]