caldav: Add import test case from RFC Appendix B

This commit is contained in:
Lennart
2025-12-31 17:55:30 +01:00
parent 4112347e24
commit da718dd290
7 changed files with 347 additions and 17 deletions

View File

@@ -38,11 +38,15 @@ END:VCALENDAR
";
#[rstest]
#[case(0, ICAL)]
#[case(1, include_str!("resources/rfc4791_appb.ics"))]
#[tokio::test]
async fn test_import(
#[from(test_store_context)]
#[future]
context: TestStoreContext,
#[case] case: usize,
#[case] ical: &'static str,
) {
let context = context.await;
let app = get_app(context.clone());
@@ -54,7 +58,7 @@ async fn test_import(
Request::builder()
.method("IMPORT")
.uri(&url)
.body(Body::from(ICAL))
.body(Body::from(ical))
.unwrap()
};
@@ -71,7 +75,7 @@ async fn test_import(
let response = app.clone().oneshot(request).await.unwrap();
assert_eq!(response.status(), StatusCode::OK);
let body = response.extract_string().await;
insta::assert_snapshot!("import_body", body);
insta::assert_snapshot!(format!("{case}_import_body"), body);
let mut request = Request::builder()
.method("GET")
@@ -89,6 +93,6 @@ async fn test_import(
(r"UID:.+", "UID:[UID]")
]
}, {
insta::assert_snapshot!("get_body", body);
insta::assert_snapshot!(format!("{case}_get_body"), body);
});
}