This commit is contained in:
Felix Ableitner 2024-02-09 15:45:11 +01:00
parent e3954be0e8
commit f720a4aa00
2 changed files with 17 additions and 21 deletions

View File

@ -2,23 +2,6 @@ variables:
- &rust_image "rust:1.75" - &rust_image "rust:1.75"
steps: steps:
cargo_test:
image: *rust_image
environment:
LEMMY_DATABASE_URL: postgres://ibis:password@database:5432/ibis
CARGO_HOME: .cargo_home
commands:
- apt-get update
- apt-get install postgresql sudo -y --no-install-recommends --no-install-suggests
# dbinit (used by tests to create temp db) refuses to run as root so we need to setup another user
- adduser testuser
- cp /usr/local/rustup /home/testuser/.rustup -r
- chown testuser:testuser . -R
- chown testuser:testuser /home/testuser -R
- export PATH="/usr/lib/postgresql/15/bin:/usr/local/cargo/bin:$PATH"
- sudo -u testuser env "PATH=$PATH" cargo test --no-fail-fast test_create_read_and_edit_local_article
cargo_fmt: cargo_fmt:
image: *rust_image image: *rust_image
environment: environment:
@ -62,6 +45,22 @@ steps:
- rustup component add clippy - rustup component add clippy
- cargo clippy --tests --all-targets --all-features - cargo clippy --tests --all-targets --all-features
cargo_test:
image: *rust_image
environment:
LEMMY_DATABASE_URL: postgres://ibis:password@database:5432/ibis
CARGO_HOME: .cargo_home
commands:
- apt-get update
- apt-get install postgresql sudo -y --no-install-recommends --no-install-suggests
# dbinit (used by tests to create temp db) refuses to run as root so we need to setup another user
- adduser testuser
- cp /usr/local/rustup /home/testuser/.rustup -r
- chown testuser:testuser . -R
- chown testuser:testuser /home/testuser -R
- export PATH="/usr/lib/postgresql/15/bin:/usr/local/cargo/bin:$PATH"
- sudo -u testuser env "PATH=$PATH" cargo test --no-fail-fast
services: services:
database: database:
image: postgres:15.2-alpine image: postgres:15.2-alpine

View File

@ -107,7 +107,6 @@ impl IbisInstance {
async fn start(db_path: String, port: i32, username: &str) -> Self { async fn start(db_path: String, port: i32, username: &str) -> Self {
let database_url = format!("postgresql://ibis:password@/ibis?host={db_path}"); let database_url = format!("postgresql://ibis:password@/ibis?host={db_path}");
let hostname = format!("localhost:{port}"); let hostname = format!("localhost:{port}");
dbg!(&hostname);
let bind = format!("127.0.0.1:{port}").parse().unwrap(); let bind = format!("127.0.0.1:{port}").parse().unwrap();
let config = IbisConfig { let config = IbisConfig {
bind, bind,
@ -120,8 +119,7 @@ impl IbisInstance {
..Default::default() ..Default::default()
}; };
let handle = tokio::task::spawn(async move { let handle = tokio::task::spawn(async move {
dbg!("do start"); start(config).await.unwrap();
dbg!(start(config).await).unwrap();
}); });
// wait a moment for the backend to start // wait a moment for the backend to start
tokio::time::sleep(Duration::from_millis(2000)).await; tokio::time::sleep(Duration::from_millis(2000)).await;
@ -131,7 +129,6 @@ impl IbisInstance {
}; };
let client = ClientBuilder::new().cookie_store(true).build().unwrap(); let client = ClientBuilder::new().cookie_store(true).build().unwrap();
let api_client = ApiClient::new(client, hostname.clone()); let api_client = ApiClient::new(client, hostname.clone());
dbg!("do register");
api_client.register(form).await.unwrap(); api_client.register(form).await.unwrap();
Self { Self {
api_client, api_client,