Page MenuHomePhabricator

D4247.id13710.diff
No OneTemporary

D4247.id13710.diff

diff --git a/services/commtest/tests/backup/add_attachments.rs b/services/commtest/tests/backup/add_attachments.rs
new file mode 100644
--- /dev/null
+++ b/services/commtest/tests/backup/add_attachments.rs
@@ -0,0 +1,53 @@
+#[path = "./backup_utils.rs"]
+mod backup_utils;
+#[path = "../lib/tools.rs"]
+mod tools;
+
+use crate::backup_utils::{proto::AddAttachmentsRequest, BackupServiceClient};
+
+use tonic::Request;
+
+use crate::backup_utils::BackupData;
+use crate::tools::{Error, ATTACHMENT_DELIMITER};
+
+// log_index = None means that we add attachments to the backup
+// log_index = Some(x) means that we add attachments to a specific log
+pub async fn run(
+ client: &mut BackupServiceClient<tonic::transport::Channel>,
+ backup_data: &BackupData,
+ log_index: Option<usize>,
+) -> Result<(), Error> {
+ let cloned_user_id = backup_data.user_id.clone();
+ let cloned_backup_id = backup_data.backup_item.id.clone();
+ let log_id: String = match log_index {
+ Some(index) => {
+ let log_id = backup_data.log_items[index].id.clone();
+ println!("add attachments for log {}/{}", index, log_id);
+ log_id
+ },
+ None => {
+ println!("add attachments for backup");
+ String::new()
+ },
+ };
+
+ let holders: String = match log_index {
+ Some(log_index) => backup_data.log_items[log_index]
+ .attachments_holders
+ .join(&ATTACHMENT_DELIMITER.to_string()[..]),
+ None => backup_data
+ .backup_item
+ .attachments_holders
+ .join(&ATTACHMENT_DELIMITER.to_string()[..]),
+ };
+
+ client
+ .add_attachments(Request::new(AddAttachmentsRequest {
+ user_id: cloned_user_id,
+ backup_id: cloned_backup_id,
+ log_id,
+ holders,
+ }))
+ .await?;
+ Ok(())
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 5:36 PM (19 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2685897
Default Alt Text
D4247.id13710.diff (1 KB)

Event Timeline