mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-17 06:29:30 +00:00
integration tests: Fix snapshot naming
This commit is contained in:
@@ -75,12 +75,31 @@ async fn test_caldav_calendar(
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Try OPTIONS without authentication
|
||||||
|
let request = Request::builder()
|
||||||
|
.method("OPTIONS")
|
||||||
|
.uri(&url)
|
||||||
|
.body(Body::empty())
|
||||||
|
.unwrap();
|
||||||
|
let response = app.clone().oneshot(request).await.unwrap();
|
||||||
|
insta::assert_debug_snapshot!(response, @r#"
|
||||||
|
Response {
|
||||||
|
status: 200,
|
||||||
|
version: HTTP/1.1,
|
||||||
|
headers: {
|
||||||
|
"dav": "1, 3, access-control, calendar-access, webdav-push",
|
||||||
|
"allow": "PROPFIND, PROPPATCH, COPY, MOVE, DELETE, OPTIONS, REPORT, GET, HEAD, POST, MKCOL, MKCALENDAR, IMPORT",
|
||||||
|
},
|
||||||
|
body: Body(
|
||||||
|
UnsyncBoxBody,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
"#);
|
||||||
|
|
||||||
// Try without authentication
|
// Try without authentication
|
||||||
let request = request_template();
|
let request = request_template();
|
||||||
let response = app.clone().oneshot(request).await.unwrap();
|
let response = app.clone().oneshot(request).await.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
||||||
let body = response.extract_string().await;
|
|
||||||
insta::assert_snapshot!(body);
|
|
||||||
|
|
||||||
// Try with correct credentials
|
// Try with correct credentials
|
||||||
let mut request = request_template();
|
let mut request = request_template();
|
||||||
@@ -90,7 +109,7 @@ async fn test_caldav_calendar(
|
|||||||
let response = app.clone().oneshot(request).await.unwrap();
|
let response = app.clone().oneshot(request).await.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::CREATED);
|
assert_eq!(response.status(), StatusCode::CREATED);
|
||||||
let body = response.extract_string().await;
|
let body = response.extract_string().await;
|
||||||
insta::assert_snapshot!(body);
|
insta::assert_snapshot!("mkcalendar_body", body);
|
||||||
|
|
||||||
let mut request = Request::builder()
|
let mut request = Request::builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
@@ -103,7 +122,7 @@ async fn test_caldav_calendar(
|
|||||||
let response = app.clone().oneshot(request).await.unwrap();
|
let response = app.clone().oneshot(request).await.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::OK);
|
assert_eq!(response.status(), StatusCode::OK);
|
||||||
let body = response.extract_string().await;
|
let body = response.extract_string().await;
|
||||||
insta::assert_snapshot!(body);
|
insta::assert_snapshot!("get_body", body);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
cal_store
|
cal_store
|
||||||
@@ -130,7 +149,7 @@ async fn test_caldav_calendar(
|
|||||||
(r"<PUSH:topic>[0-9a-f-]+</PUSH:topic>", "<PUSH:topic>[PUSH_TOPIC]</PUSH:topic>")
|
(r"<PUSH:topic>[0-9a-f-]+</PUSH:topic>", "<PUSH:topic>[PUSH_TOPIC]</PUSH:topic>")
|
||||||
]
|
]
|
||||||
}, {
|
}, {
|
||||||
insta::assert_snapshot!(body);
|
insta::assert_snapshot!("propfind_body", body);
|
||||||
});
|
});
|
||||||
|
|
||||||
let proppatch_request: &str = r#"
|
let proppatch_request: &str = r#"
|
||||||
@@ -159,7 +178,7 @@ async fn test_caldav_calendar(
|
|||||||
let response = app.clone().oneshot(request).await.unwrap();
|
let response = app.clone().oneshot(request).await.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::MULTI_STATUS);
|
assert_eq!(response.status(), StatusCode::MULTI_STATUS);
|
||||||
let body = response.extract_string().await;
|
let body = response.extract_string().await;
|
||||||
insta::assert_snapshot!(body);
|
insta::assert_snapshot!("proppatch_body", body);
|
||||||
|
|
||||||
calendar_meta.displayname = Some("New Displayname".to_string());
|
calendar_meta.displayname = Some("New Displayname".to_string());
|
||||||
calendar_meta.description = None;
|
calendar_meta.description = None;
|
||||||
@@ -185,7 +204,7 @@ async fn test_caldav_calendar(
|
|||||||
let response = app.clone().oneshot(request).await.unwrap();
|
let response = app.clone().oneshot(request).await.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::OK);
|
assert_eq!(response.status(), StatusCode::OK);
|
||||||
let body = response.extract_string().await;
|
let body = response.extract_string().await;
|
||||||
insta::assert_snapshot!(body);
|
insta::assert_snapshot!("delete_body", body);
|
||||||
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
cal_store.get_calendar(principal, cal_id, false).await,
|
cal_store.get_calendar(principal, cal_id, false).await,
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ async fn test_caldav_root(
|
|||||||
let request = request_template();
|
let request = request_template();
|
||||||
let response = app.clone().oneshot(request).await.unwrap();
|
let response = app.clone().oneshot(request).await.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
||||||
let body = response.extract_string().await;
|
|
||||||
insta::assert_snapshot!(body);
|
|
||||||
|
|
||||||
// Try with wrong password
|
// Try with wrong password
|
||||||
let mut request = request_template();
|
let mut request = request_template();
|
||||||
@@ -39,8 +37,6 @@ async fn test_caldav_root(
|
|||||||
.typed_insert(Authorization::basic("user", "wrongpass"));
|
.typed_insert(Authorization::basic("user", "wrongpass"));
|
||||||
let response = app.clone().oneshot(request).await.unwrap();
|
let response = app.clone().oneshot(request).await.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
||||||
let body = response.extract_string().await;
|
|
||||||
insta::assert_snapshot!(body);
|
|
||||||
|
|
||||||
// Try with correct credentials
|
// Try with correct credentials
|
||||||
let mut request = request_template();
|
let mut request = request_template();
|
||||||
@@ -51,7 +47,7 @@ async fn test_caldav_root(
|
|||||||
let response = app.oneshot(request).await.unwrap();
|
let response = app.oneshot(request).await.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::MULTI_STATUS);
|
assert_eq!(response.status(), StatusCode::MULTI_STATUS);
|
||||||
let body = response.extract_string().await;
|
let body = response.extract_string().await;
|
||||||
insta::assert_snapshot!(body);
|
insta::assert_snapshot!("propfind_body", body);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -75,8 +71,6 @@ async fn test_caldav_principal(
|
|||||||
let request = request_template();
|
let request = request_template();
|
||||||
let response = app.clone().oneshot(request).await.unwrap();
|
let response = app.clone().oneshot(request).await.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
||||||
let body = response.extract_string().await;
|
|
||||||
insta::assert_snapshot!(body);
|
|
||||||
|
|
||||||
// Try with wrong password
|
// Try with wrong password
|
||||||
let mut request = request_template();
|
let mut request = request_template();
|
||||||
@@ -85,8 +79,6 @@ async fn test_caldav_principal(
|
|||||||
.typed_insert(Authorization::basic("user", "wrongpass"));
|
.typed_insert(Authorization::basic("user", "wrongpass"));
|
||||||
let response = app.clone().oneshot(request).await.unwrap();
|
let response = app.clone().oneshot(request).await.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
||||||
let body = response.extract_string().await;
|
|
||||||
insta::assert_snapshot!(body);
|
|
||||||
|
|
||||||
// Try with correct credentials
|
// Try with correct credentials
|
||||||
let mut request = request_template();
|
let mut request = request_template();
|
||||||
@@ -96,7 +88,7 @@ async fn test_caldav_principal(
|
|||||||
let response = app.clone().oneshot(request).await.unwrap();
|
let response = app.clone().oneshot(request).await.unwrap();
|
||||||
assert_eq!(response.status(), StatusCode::MULTI_STATUS);
|
assert_eq!(response.status(), StatusCode::MULTI_STATUS);
|
||||||
let body = response.extract_string().await;
|
let body = response.extract_string().await;
|
||||||
insta::assert_snapshot!(body);
|
insta::assert_snapshot!("propfind_depth_0", body);
|
||||||
|
|
||||||
// Try with Depth: 1
|
// Try with Depth: 1
|
||||||
let mut request = request_template();
|
let mut request = request_template();
|
||||||
@@ -114,6 +106,6 @@ async fn test_caldav_principal(
|
|||||||
(r"<PUSH:topic>[0-9a-f-]+</PUSH:topic>", "<PUSH:topic>[PUSH_TOPIC]</PUSH:topic>")
|
(r"<PUSH:topic>[0-9a-f-]+</PUSH:topic>", "<PUSH:topic>[PUSH_TOPIC]</PUSH:topic>")
|
||||||
]
|
]
|
||||||
}, {
|
}, {
|
||||||
insta::assert_snapshot!(body);
|
insta::assert_snapshot!("propfind_depth_1", body);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
source: src/integration_tests/caldav/mod.rs
|
|
||||||
expression: body
|
|
||||||
---
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
source: src/integration_tests/caldav/mod.rs
|
|
||||||
expression: body
|
|
||||||
---
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
source: src/integration_tests/caldav/mod.rs
|
|
||||||
expression: body
|
|
||||||
---
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
source: src/integration_tests/caldav/mod.rs
|
|
||||||
expression: body
|
|
||||||
---
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
source: src/integration_tests/caldav/calendar.rs
|
|
||||||
expression: body
|
|
||||||
---
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user