From 5d3eaa9863e6d3973fe2e4b7f54fa8a8ed18c03a Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 29 Nov 2024 13:45:59 +0000 Subject: [PATCH] task(backup_tests): Split exists_on_server test into separate tests --- .../matrix-sdk/src/encryption/backups/mod.rs | 54 +++++++++++-------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/crates/matrix-sdk/src/encryption/backups/mod.rs b/crates/matrix-sdk/src/encryption/backups/mod.rs index 4d017aa46a3..bf64e580b42 100644 --- a/crates/matrix-sdk/src/encryption/backups/mod.rs +++ b/crates/matrix-sdk/src/encryption/backups/mod.rs @@ -1119,35 +1119,47 @@ mod test { } #[async_test] - async fn test_exists_on_server() { + async fn test_when_a_backup_exists_then_exists_on_server_returns_true() { let server = MockServer::start().await; let client = logged_in_client(Some(server.uri())).await; - { - let _scope = mock_backup_exists(&server).await; + let _scope = mock_backup_exists(&server).await; - let exists = client - .encryption() - .backups() - .exists_on_server() - .await - .expect("We should be able to check if backups exist on the server"); + let exists = client + .encryption() + .backups() + .exists_on_server() + .await + .expect("We should be able to check if backups exist on the server"); - assert!(exists, "We should deduce that a backup exists on the server"); - } + assert!(exists, "We should deduce that a backup exists on the server"); - { - let _scope = mock_backup_none(&server).await; + server.verify().await; + } - let exists = client - .encryption() - .backups() - .exists_on_server() - .await - .expect("We should be able to check if backups exist on the server"); + #[async_test] + async fn test_when_no_backup_exists_then_exists_on_server_returns_false() { + let server = MockServer::start().await; + let client = logged_in_client(Some(server.uri())).await; - assert!(!exists, "We should deduce that no backup exists on the server"); - } + let _scope = mock_backup_none(&server).await; + + let exists = client + .encryption() + .backups() + .exists_on_server() + .await + .expect("We should be able to check if backups exist on the server"); + + assert!(!exists, "We should deduce that no backup exists on the server"); + + server.verify().await; + } + + #[async_test] + async fn test_when_server_returns_an_error_then_exists_on_server_returns_an_error() { + let server = MockServer::start().await; + let client = logged_in_client(Some(server.uri())).await; { let _scope = mock_backup_too_many_requests(&server).await;