From a79dd14c5dc3680035386488ea26086b687a85ec Mon Sep 17 00:00:00 2001 From: Mauro D Date: Wed, 19 Apr 2023 17:17:56 +0000 Subject: [PATCH] Email get tests. --- crates/jmap-proto/src/types/value.rs | 11 -- .../jmap_mail_get/message_attachment.failed | 109 ------------------ tests/src/jmap/mod.rs | 3 +- 3 files changed, 2 insertions(+), 121 deletions(-) delete mode 100644 tests/resources/jmap_mail_get/message_attachment.failed diff --git a/crates/jmap-proto/src/types/value.rs b/crates/jmap-proto/src/types/value.rs index ec5369e8..09f2becf 100644 --- a/crates/jmap-proto/src/types/value.rs +++ b/crates/jmap-proto/src/types/value.rs @@ -5,7 +5,6 @@ use serde::Serialize; use store::BlobKind; use crate::{ - error::method::MethodError, object::Object, parser::{json::Parser, Ignore, JsonObjectParser, Token}, request::reference::{MaybeReference, ResultReference}, @@ -156,16 +155,6 @@ impl Value { _ => Value::parse::(parser), } } - - pub fn as_blob(&self) -> Result<&BlobId, MethodError> { - match self { - Value::BlobId(blob) => Ok(blob), - _ => { - let log = "log"; - Err(MethodError::ServerPartialFail) - } - } - } } impl JsonObjectParser for SetValueMap { diff --git a/tests/resources/jmap_mail_get/message_attachment.failed b/tests/resources/jmap_mail_get/message_attachment.failed deleted file mode 100644 index cd6b33b2..00000000 --- a/tests/resources/jmap_mail_get/message_attachment.failed +++ /dev/null @@ -1,109 +0,0 @@ -{ - "mailboxIds": { - "a": true - }, - "keywords": { - "tag": true - }, - "size": 2651, - "receivedAt": "2054-01-02T20:53:20Z", - "from": [ - { - "name": "Al Gore", - "email": "vice-president@whitehouse.gov" - } - ], - "to": [ - { - "name": "White House Transportation Coordinator", - "email": "transport@whitehouse.gov" - } - ], - "subject": "[Fwd: Map of Argentina with Description]", - "bodyStructure": { - "partId": "0", - "headers": [ - { - "name": "From", - "value": " Al Gore " - }, - { - "name": "To", - "value": " White House Transportation Coordinator\n " - }, - { - "name": "Subject", - "value": " [Fwd: Map of Argentina with Description]" - }, - { - "name": "Content-Type", - "value": " multipart/mixed;\n boundary=\"D7F------------D7FD5A0B8AB9C65CCDBFA872\"" - } - ], - "type": "multipart/mixed" - }, - "bodyValues": {}, - "textBody": [ - { - "partId": "1", - "blobId": "blob_0", - "size": 61, - "headers": [ - { - "name": "Content-Type", - "value": " text/plain; charset=us-ascii" - }, - { - "name": "Content-Transfer-Encoding", - "value": " 7bit" - } - ], - "type": "text/plain", - "charset": "us-ascii" - } - ], - "htmlBody": [ - { - "partId": "1", - "blobId": "blob_0", - "size": 61, - "headers": [ - { - "name": "Content-Type", - "value": " text/plain; charset=us-ascii" - }, - { - "name": "Content-Transfer-Encoding", - "value": " 7bit" - } - ], - "type": "text/plain", - "charset": "us-ascii" - } - ], - "attachments": [ - { - "partId": "2", - "blobId": "blob_2", - "size": 1979, - "headers": [ - { - "name": "Content-Type", - "value": " message/rfc822" - }, - { - "name": "Content-Transfer-Encoding", - "value": " 7bit" - }, - { - "name": "Content-Disposition", - "value": " inline" - } - ], - "type": "message/rfc822", - "disposition": "inline" - } - ], - "hasAttachment": true, - "preview": "Fred,\n\nFire up Air Force One! We're going South!\n\nThanks,\nAl" -} \ No newline at end of file diff --git a/tests/src/jmap/mod.rs b/tests/src/jmap/mod.rs index 97838425..49f7f2a4 100644 --- a/tests/src/jmap/mod.rs +++ b/tests/src/jmap/mod.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::{collections::BTreeSet, sync::Arc}; use jmap::{api::SessionManager, JMAP}; use jmap_client::client::{Client, Credentials}; @@ -136,6 +136,7 @@ pub fn replace_boundaries(string: String) -> String { pub fn replace_blob_ids(string: String) -> String { let values = find_values(&string, "blobId\":"); if !values.is_empty() { + let values = BTreeSet::from_iter(values).into_iter().collect::>(); replace_values( string, &values,