mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 20:31:19 +00:00
try to init db from lemmy in tests
This commit is contained in:
parent
7e7e27a7eb
commit
08748bbede
5 changed files with 22 additions and 4 deletions
|
@ -34,9 +34,6 @@ steps:
|
||||||
commands:
|
commands:
|
||||||
- sudo apt-get update
|
- sudo apt-get update
|
||||||
- sudo apt-get -y install --no-install-recommends espeak postgresql-client
|
- sudo apt-get -y install --no-install-recommends espeak postgresql-client
|
||||||
- cargo install diesel_cli --no-default-features --features postgres --target-dir target/
|
|
||||||
- ls -la target/
|
|
||||||
- ./target/diesel migration run
|
|
||||||
- cargo test --workspace --no-fail-fast
|
- cargo test --workspace --no-fail-fast
|
||||||
|
|
||||||
- name: cargo build
|
- name: cargo build
|
||||||
|
|
11
Cargo.lock
generated
11
Cargo.lock
generated
|
@ -935,6 +935,16 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ctor"
|
||||||
|
version = "0.1.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7fbaabec2c953050352311293be5c6aba8e141ba19d6811862b232d6fd020484"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "darling"
|
name = "darling"
|
||||||
version = "0.10.2"
|
version = "0.10.2"
|
||||||
|
@ -1838,6 +1848,7 @@ dependencies = [
|
||||||
"awc",
|
"awc",
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"ctor",
|
||||||
"diesel",
|
"diesel",
|
||||||
"diesel_migrations",
|
"diesel_migrations",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
|
|
@ -49,6 +49,7 @@ reqwest = { version = "0.10", features = ["json"] }
|
||||||
activitystreams = "0.7.0-alpha.4"
|
activitystreams = "0.7.0-alpha.4"
|
||||||
actix-rt = { version = "1.1", default-features = false }
|
actix-rt = { version = "1.1", default-features = false }
|
||||||
serde_json = { version = "1.0", features = ["preserve_order"]}
|
serde_json = { version = "1.0", features = ["preserve_order"]}
|
||||||
|
ctor = "0.1.16"
|
||||||
|
|
||||||
[dev-dependencies.cargo-husky]
|
[dev-dependencies.cargo-husky]
|
||||||
version = "1"
|
version = "1"
|
||||||
|
|
|
@ -214,7 +214,7 @@ lazy_static! {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
pub mod tests {
|
||||||
use super::fuzzy_search;
|
use super::fuzzy_search;
|
||||||
use crate::{get_database_url_from_env, is_email_regex};
|
use crate::{get_database_url_from_env, is_email_regex};
|
||||||
use diesel::{Connection, PgConnection};
|
use diesel::{Connection, PgConnection};
|
||||||
|
|
|
@ -92,3 +92,12 @@ async fn main() -> Result<(), LemmyError> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[ctor::ctor]
|
||||||
|
fn init() {
|
||||||
|
use lemmy_db::tests::establish_unpooled_connection;
|
||||||
|
let conn = establish_unpooled_connection();
|
||||||
|
embedded_migrations::run(&conn).unwrap();
|
||||||
|
run_advanced_migrations(&conn).unwrap();
|
||||||
|
}
|
Loading…
Reference in a new issue