Add initial test for app initialisation

This commit is contained in:
Lennart
2025-12-10 14:43:06 +01:00
parent 8fadff1b57
commit 4b4210b4d7
4 changed files with 61 additions and 0 deletions

2
Cargo.lock generated
View File

@@ -3069,6 +3069,7 @@ dependencies = [
"figment",
"headers",
"http",
"insta",
"opentelemetry",
"opentelemetry-otlp",
"opentelemetry-semantic-conventions",
@@ -3078,6 +3079,7 @@ dependencies = [
"quick-xml",
"reqwest",
"rpassword",
"rstest",
"rustical_caldav",
"rustical_carddav",
"rustical_dav",

View File

@@ -151,6 +151,11 @@ async-std = { version = "1.13", features = ["attributes"] }
similar-asserts = "1.7"
insta = "1.44"
[dev-dependencies]
rstest.workspace = true
rustical_store_sqlite = { workspace = true, features = ["test"] }
insta.workspace = true
[dependencies]
rustical_store.workspace = true
rustical_store_sqlite.workspace = true

View File

@@ -31,6 +31,8 @@ mod app;
mod commands;
mod config;
mod setup_tracing;
#[cfg(test)]
mod tests;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]

52
src/tests.rs Normal file
View File

@@ -0,0 +1,52 @@
use crate::{app::make_app, config::NextcloudLoginConfig};
use rstest::rstest;
use rustical_frontend::FrontendConfig;
use rustical_store_sqlite::{
SqliteStore,
addressbook_store::SqliteAddressbookStore,
calendar_store::SqliteCalendarStore,
principal_store::SqlitePrincipalStore,
tests::{
get_test_addressbook_store, get_test_calendar_store, get_test_principal_store,
get_test_subscription_store,
},
};
use std::sync::Arc;
#[rstest]
#[tokio::test]
async fn test_app(
#[from(get_test_calendar_store)]
#[future]
cal_store: SqliteCalendarStore,
#[from(get_test_addressbook_store)]
#[future]
addr_store: SqliteAddressbookStore,
#[from(get_test_principal_store)]
#[future]
principal_store: SqlitePrincipalStore,
#[from(get_test_subscription_store)]
#[future]
sub_store: SqliteStore,
) {
let addr_store = Arc::new(addr_store.await);
let cal_store = Arc::new(cal_store.await);
let sub_store = Arc::new(sub_store.await);
let principal_store = Arc::new(principal_store.await);
let _app = make_app(
addr_store,
cal_store,
sub_store,
principal_store,
FrontendConfig {
enabled: true,
allow_password_login: true,
},
None,
&NextcloudLoginConfig { enabled: false },
false,
true,
20,
);
}