Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions crates/iris-cli/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,8 @@ mod tests {
.expect("accented code point")
+ 1;
let mut parser = SseParser::new();
assert!(parser.feed(&bytes[..=first_cr]).is_empty());
assert!(parser.feed(&rest[..utf8_split]).is_empty());
assert_eq!(parser.feed(&bytes[..=first_cr]), Vec::<SseFrame>::new());
assert_eq!(parser.feed(&rest[..utf8_split]), Vec::<SseFrame>::new());
assert_eq!(
parser.feed(&rest[utf8_split..]),
vec![SseFrame::Message {
Expand All @@ -477,8 +477,8 @@ mod tests {
#[test]
fn parser_handles_split_chunks() {
let mut parser = SseParser::new();
assert!(parser.feed(b"event: mes").is_empty());
assert!(parser.feed(b"sage\ndata: {\"a\":").is_empty());
assert_eq!(parser.feed(b"event: mes"), Vec::<SseFrame>::new());
assert_eq!(parser.feed(b"sage\ndata: {\"a\":"), Vec::<SseFrame>::new());
assert_eq!(
parser.feed(b"1}\n\n"),
vec![SseFrame::Message {
Expand Down Expand Up @@ -525,10 +525,9 @@ mod tests {
#[test]
fn parser_finish_flushes_partial_frame() {
let mut parser = SseParser::new();
assert!(
parser
.feed(b"event: error\ndata: {\"code\":\"provider_failed\"}")
.is_empty()
assert_eq!(
parser.feed(b"event: error\ndata: {\"code\":\"provider_failed\"}"),
Vec::<SseFrame>::new()
);
assert_eq!(
parser.finish(),
Expand All @@ -543,7 +542,7 @@ mod tests {
#[test]
fn parser_handles_cr_newlines() {
let mut parser = SseParser::new();
assert!(parser.feed(b"event: message\r").is_empty());
assert_eq!(parser.feed(b"event: message\r"), Vec::<SseFrame>::new());
assert_eq!(
parser.feed(b"data: {\"ok\":1}\n\n"),
vec![SseFrame::Message {
Expand Down Expand Up @@ -572,16 +571,16 @@ mod tests {
#[test]
fn parser_split_crlf_does_not_clear_frame_id_or_duplicate_frame() {
let mut parser = SseParser::new();
assert!(parser.feed(b"id: cursor-1\r").is_empty());
assert!(parser.feed(&[]).is_empty());
assert_eq!(parser.feed(b"id: cursor-1\r"), Vec::<SseFrame>::new());
assert_eq!(parser.feed(&[]), Vec::<SseFrame>::new());
assert_eq!(
parser.feed(b"\ndata: {\"ok\":1}\r\n\r\n"),
vec![SseFrame::Message {
id: Some("cursor-1".into()),
data: "{\"ok\":1}".into(),
}]
);
assert!(parser.finish().is_empty());
assert_eq!(parser.finish(), Vec::<SseFrame>::new());
}

/// The server URL comes from the environment with a sane default.
Expand Down Expand Up @@ -694,7 +693,7 @@ mod tests {
.await
.unwrap();
assert!(should_exit);
assert!(out.is_empty());
assert_eq!(out, Vec::<u8>::new());
assert!(
String::from_utf8(err)
.unwrap()
Expand Down Expand Up @@ -771,7 +770,7 @@ mod tests {
.await
.unwrap();
assert!(should_exit);
assert!(out.is_empty());
assert_eq!(out, Vec::<u8>::new());
let diagnostic = String::from_utf8(err).unwrap();
assert!(diagnostic.contains(expected_diagnostic), "{diagnostic}");
assert!(
Expand Down Expand Up @@ -803,7 +802,7 @@ mod tests {
.await
.unwrap();
assert!(!should_exit);
assert!(err.is_empty());
assert_eq!(err, Vec::<u8>::new());
let value: serde_json::Value = serde_json::from_slice(&out).unwrap();
assert_eq!(value["cursor"], "cursor-1");
assert_eq!(
Expand Down
3 changes: 3 additions & 0 deletions crates/iris-core/src/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ pub enum RecordOutcome {
}

/// Append-only, provider-agnostic audit storage.
// Trait methods return `Result`, which is already `#[must_use]`; suppress the
// redundant-attribute lint that rust 1.99's clippy raises on async traits.
#[allow(clippy::double_must_use)]
#[async_trait]
pub trait AuditLog: std::fmt::Debug + Send + Sync {
/// Append an event and return its hash-linked entry.
Expand Down
3 changes: 3 additions & 0 deletions crates/iris-core/src/ingest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ pub enum IngestOutcome {
}

/// Durable all-or-nothing normalized-object ingestion.
// Trait methods return `Result`, which is already `#[must_use]`; suppress the
// redundant-attribute lint that rust 1.99's clippy raises on async traits.
#[allow(clippy::double_must_use)]
#[async_trait]
pub trait IngestStore: std::fmt::Debug + Send + Sync {
/// Apply the batch, replay record, cursor, and audit event atomically.
Expand Down
3 changes: 3 additions & 0 deletions crates/iris-core/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ impl ProviderMetadata {
/// Providers normalize their source-specific data into Iris's unified model.
/// The trait is async because all providers involve some form of I/O
/// (API calls, database queries, webhook processing).
// Trait methods return `Result`, which is already `#[must_use]`; suppress the
// redundant-attribute lint that rust 1.99's clippy raises on async traits.
#[allow(clippy::double_must_use)]
#[async_trait]
pub trait MessageProvider: Send + Sync {
/// Static metadata about this provider.
Expand Down
3 changes: 3 additions & 0 deletions crates/iris-core/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ pub struct AttachmentRef {
/// Implementations are responsible for persisting attachment bytes and
/// returning stable, resolvable references. The trait is async because
/// all storage backends involve I/O.
// Trait methods return `Result`, which is already `#[must_use]`; suppress the
// redundant-attribute lint that rust 1.99's clippy raises on async traits.
#[allow(clippy::double_must_use)]
#[async_trait]
pub trait AttachmentStore: std::fmt::Debug + Send + Sync {
/// Store attachment content, returning a reference with assigned ID and URL.
Expand Down
15 changes: 12 additions & 3 deletions crates/iris-core/src/wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,18 @@ mod tests {

#[test]
fn absent_and_null_attachments_decode_to_empty() {
assert!(decode_attachments(None).unwrap().is_empty());
assert!(decode(&json!(null)).unwrap().is_empty());
assert!(decode(&json!([])).unwrap().is_empty());
assert_eq!(
decode_attachments(None).unwrap(),
Vec::<OutboundAttachment>::new()
);
assert_eq!(
decode(&json!(null)).unwrap(),
Vec::<OutboundAttachment>::new()
);
assert_eq!(
decode(&json!([])).unwrap(),
Vec::<OutboundAttachment>::new()
);
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions crates/iris-providers/src/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ mod tests {
let store = test_store();

// Before storage, the URL is a provider pseudo-URL.
assert!(!email.attachments.is_empty());
assert_ne!(email.attachments, [] as [iris_core::Attachment; 0]);
assert!(email.attachments[0].url.starts_with("email:message:"));

email
Expand Down Expand Up @@ -1312,7 +1312,7 @@ mod tests {
.store_attachments(&store)
.await
.expect("no-op succeeds");
assert!(email.attachments.is_empty());
assert_eq!(email.attachments, [] as [iris_core::Attachment; 0]);
}

#[test]
Expand Down Expand Up @@ -1510,7 +1510,7 @@ mod tests {
..Default::default()
};
let selected = select_uids(Vec::new(), &opts, 500);
assert!(selected.is_empty());
assert_eq!(selected, [] as [u32; 0]);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/iris-providers/src/herdr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ mod tests {
})
.unwrap();

assert!(batch.mutations.is_empty());
assert_eq!(batch.mutations, [] as [iris_core::IngestMutation; 0]);
let audit = batch
.audit
.as_ref()
Expand Down
2 changes: 1 addition & 1 deletion crates/iris-providers/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ mod tests {
.send_message("thread-7", &OutboundMessage::text("plain"))
.await
.expect("text send succeeds");
assert!(message.attachments.is_empty());
assert_eq!(message.attachments, [] as [iris_core::Attachment; 0]);
assert_eq!(
provider.recorded_sends().expect("records readable").len(),
2
Expand Down
5 changes: 4 additions & 1 deletion crates/iris-providers/src/telegram/realtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,10 @@ mod tests {
TelegramProvider::with_base_url("123:abc", server.uri(), Arc::new(InMemoryStore))
.expect("provider builds");
let hub = provider.realtime_hub().expect("valid realtime settings");
assert!(hub.snapshot_messages(provider.clone()).is_empty());
assert_eq!(
hub.snapshot_messages(provider.clone()),
[] as [iris_core::Message; 0]
);

for _ in 0..200 {
if hub.cursor() == 101 {
Expand Down
2 changes: 1 addition & 1 deletion crates/iris-server/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct ProviderResponse {
}

pub fn router(state: AppState) -> Router {
debug_assert!(!generated::GENERATED_ROUTES.is_empty());
debug_assert_ne!(generated::GENERATED_ROUTES, []);
let generated = generated::generated_router()
.layer(middleware::from_fn_with_state(state.clone(), ingest_auth));
let router = Router::new()
Expand Down
Loading