From: Felix Ableitner Date: Mon, 4 Jan 2021 17:12:37 +0000 (+0100) Subject: Fix integration tests (except one) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/%22%7Burl%7D/%7Biframely.url%7D?a=commitdiff_plain;h=7bc943459610c37f3ae5c5bdb8abde8a1a2093dc;p=lemmy.git Fix integration tests (except one) --- diff --git a/tests/integration_test.rs b/tests/integration_test.rs index d97cb72f..5e6964e4 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -1,5 +1,7 @@ extern crate lemmy_server; +#[macro_use] +extern crate diesel_migrations; use activitystreams::{ activity::{ kind::{CreateType, FollowType}, @@ -28,11 +30,12 @@ use lemmy_apub::{ user_inbox::user_inbox, }, }; -use lemmy_db_queries::{Crud, ListingType, SortType}; +use lemmy_db_queries::{get_database_url_from_env, Crud, ListingType, SortType}; use lemmy_db_schema::source::{ community::{Community, CommunityForm}, user::{UserForm, User_}, }; +use lemmy_server::code_migrations::run_advanced_migrations; use lemmy_utils::{ apub::generate_actor_keypair, rate_limit::{rate_limiter::RateLimiter, RateLimit}, @@ -41,18 +44,25 @@ use lemmy_utils::{ use lemmy_websocket::{chat_server::ChatServer, LemmyContext}; use reqwest::Client; use serde::{Deserialize, Serialize}; -use std::sync::Arc; +use std::{ops::Deref, sync::Arc}; use tokio::sync::Mutex; use url::Url; +embed_migrations!(); + fn create_context() -> LemmyContext { let settings = Settings::get(); - let db_url = settings.get_database_url(); + let db_url = match get_database_url_from_env() { + Ok(url) => url, + Err(_) => settings.get_database_url(), + }; let manager = ConnectionManager::::new(&db_url); let pool = Pool::builder() .max_size(settings.database.pool_size) .build(manager) .unwrap(); + embedded_migrations::run(&pool.get().unwrap()).unwrap(); + run_advanced_migrations(pool.get().unwrap().deref()).unwrap(); let rate_limiter = RateLimit { rate_limiter: Arc::new(Mutex::new(RateLimiter::default())), }; @@ -154,6 +164,7 @@ fn create_http_request() -> HttpRequest { .to_http_request() } +// TODO: this fails with a stack overflow for some reason #[actix_rt::test] #[ignore] async fn test_shared_inbox_expired_signature() { @@ -172,7 +183,6 @@ async fn test_shared_inbox_expired_signature() { } #[actix_rt::test] -#[ignore] async fn test_user_inbox_expired_signature() { let request = create_http_request(); let context = create_context(); @@ -192,7 +202,6 @@ async fn test_user_inbox_expired_signature() { } #[actix_rt::test] -#[ignore] async fn test_community_inbox_expired_signature() { let context = create_context(); let connection = &context.pool().get().unwrap();