diff --git a/services/commtest/tests/backup_test.rs b/services/commtest/tests/backup_test.rs --- a/services/commtest/tests/backup_test.rs +++ b/services/commtest/tests/backup_test.rs @@ -20,7 +20,9 @@ #[tokio::test] async fn backup_test() -> Result<(), Error> { let mut client = - BackupServiceClient::connect("http://localhost:50052").await?; + BackupServiceClient::connect("http://localhost:50052").await?; + + let attachments_fill_size: u64 = 500; let mut backup_data = BackupData { user_id: "user0000".to_string(), @@ -40,7 +42,7 @@ // In this case its data should be moved to the S3 Item::new( String::new(), - vec![tools::get_dynamo_db_item_size_limit() - ByteSize::b(100).as_u64() as usize], + vec![tools::get_dynamo_db_item_size_limit() - ByteSize::b(attachments_fill_size/2).as_u64() as usize], vec!["holder0".to_string(), "holder1".to_string()], ), // just a small item @@ -77,8 +79,7 @@ assert_eq!( from_result, expected, "backup sizes do not match, expected {}, got {}", - expected, - from_result + expected, from_result ); // check backup attachments @@ -87,8 +88,7 @@ assert_eq!( from_result, expected, "backup: number of attachments holders do not match, expected {}, got {}", - expected, - from_result + expected, from_result ); // check number of logs @@ -113,25 +113,13 @@ from_result ); } - // check logs attachments - for i in 0..backup_data.log_items.len() { - let expected: usize = backup_data.log_items[i].attachments_holders.len(); - let from_result: usize = result.log_items[i].attachments_holders.len(); - assert_eq!( - from_result, expected, - "log {}: number of attachments holders do not match, expected {}, got {}", - i, - expected, - from_result - ); - } // push so many attachments that the log item's data will have to be moved // from the db to the s3 let mut attachments_size = 0; let mut i = backup_data.log_items[0].attachments_holders.len(); - let mut new_attachments: Vec = vec![]; - while attachments_size < 500 { + let mut new_attachments: Vec = Vec::new(); + while attachments_size < (attachments_fill_size as usize) { let att = format!("holder{}", i); attachments_size += att.len(); new_attachments.push(att); @@ -150,8 +138,8 @@ for i in 0..backup_data.log_items.len() { let expected: usize = backup_data.log_items[i].attachments_holders.len(); let from_result: usize = result.log_items[i].attachments_holders.len(); - assert!( - from_result == expected, + assert_eq!( + from_result, expected, "after attachment add: log {}: number of attachments holders do not match, expected {}, got {}", i,