Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

test(soup): make test targets pass clippy with ports or more (#8752)

gbirmana5db4b56dec0
diff --git a/crates/soup/src/domain/service/favorites/test.rs b/crates/soup/src/domain/service/favorites/test.rs
index 221a26c62a..a03f994d44 100644
--- a/crates/soup/src/domain/service/favorites/test.rs
+++ b/crates/soup/src/domain/service/favorites/test.rs
@@ -15,8 +15,10 @@ fn favorites_intersect_existing_filters_and_do_not_cross_entity_types() {
let kept = Uuid::from_u128(1);
let removed = Uuid::from_u128(2);
let other = Uuid::from_u128(3);
- let mut ast = EntityFilterAst::default();
- ast.favorites_only = Some(true);
+ let mut ast = EntityFilterAst {
+ favorites_only: Some(true),
+ ..Default::default()
+ };
ast.email_filter.tree = Some(Arc::new(Expr::is_not(Expr::val(EmailLiteral::ThreadId(
removed,
)))));
diff --git a/crates/soup/src/domain/service/tests.rs b/crates/soup/src/domain/service/tests.rs
index 61e71a02ae..ed7d364690 100644
--- a/crates/soup/src/domain/service/tests.rs
+++ b/crates/soup/src/domain/service/tests.rs
@@ -2888,10 +2888,13 @@ async fn touched_soup_full_page_builds_keyset_cursor() {
assert_eq!(decoded.val.last_val, last_touch);
}
+/// One email hydration request: the view, the thread ids and the limit.
+type EmailPreviewRequest = (PreviewView, Vec<Uuid>, Option<u32>);
+
/// Records each email hydration request and returns no threads.
#[derive(Clone, Default)]
struct RecordingEmailPreviewService {
- requests: Arc<Mutex<Vec<(PreviewView, Vec<Uuid>, Option<u32>)>>>,
+ requests: Arc<Mutex<Vec<EmailPreviewRequest>>>,
filters: Arc<Mutex<Vec<String>>>,
}
diff --git a/crates/soup/src/outbound/pg_soup_repo/crm_association/test.rs b/crates/soup/src/outbound/pg_soup_repo/crm_association/test.rs
index 2d4629d4f9..5108c8301d 100644
--- a/crates/soup/src/outbound/pg_soup_repo/crm_association/test.rs
+++ b/crates/soup/src/outbound/pg_soup_repo/crm_association/test.rs
@@ -11,15 +11,15 @@ async fn link(pool: &PgPool, entity_id: &str, entity_type: &str, definition: Uui
.iter()
.map(|id| serde_json::json!({ "entity_id": id.to_string(), "entity_type": "COMPANY" }))
.collect();
- sqlx::query(
+ sqlx::query!(
r#"INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)
- VALUES ($1, $2, $3::property_entity_type, $4, $5)"#,
+ VALUES ($1, $2, $3::text::property_entity_type, $4, $5)"#,
+ Uuid::now_v7(),
+ entity_id,
+ entity_type,
+ definition,
+ serde_json::json!({ "type": "EntityReference", "value": refs }),
)
- .bind(Uuid::now_v7())
- .bind(entity_id)
- .bind(entity_type)
- .bind(definition)
- .bind(serde_json::json!({ "type": "EntityReference", "value": refs }))
.execute(pool)
.await
.unwrap();
diff --git a/crates/soup/src/outbound/pg_soup_repo/expanded/dynamic/test.rs b/crates/soup/src/outbound/pg_soup_repo/expanded/dynamic/test.rs
index f0baf24d5b..2403da94fb 100644
--- a/crates/soup/src/outbound/pg_soup_repo/expanded/dynamic/test.rs
+++ b/crates/soup/src/outbound/pg_soup_repo/expanded/dynamic/test.rs
@@ -191,6 +191,10 @@ async fn grouped_query_explain_local(pool: PgPool) -> anyhow::Result<()> {
builder.sql()
);
for repetition in 1..=3 {
+ #[expect(
+ clippy::disallowed_methods,
+ reason = "explains SQL generated from the AST and grouping"
+ )]
let query = sqlx::query_scalar::<_, serde_json::Value>(&sql)
.bind("macro|[email protected]")
.bind(sort.to_string())
diff --git a/crates/soup/src/outbound/pg_soup_repo/expanded/tests.rs b/crates/soup/src/outbound/pg_soup_repo/expanded/tests.rs
index 7e8b4458f4..c3e364679f 100644
--- a/crates/soup/src/outbound/pg_soup_repo/expanded/tests.rs
+++ b/crates/soup/src/outbound/pg_soup_repo/expanded/tests.rs
@@ -6576,7 +6576,7 @@ async fn insert_notification(
done: bool,
seen: bool,
) -> anyhow::Result<()> {
- sqlx::query(
+ sqlx::query!(
r#"
INSERT INTO notification (
id,
@@ -6589,10 +6589,10 @@ async fn insert_notification(
)
VALUES ($1::uuid, 'test', $2, $3, 'test', NOW(), '{}')
"#,
+ Uuid::parse_str(notification_id)?,
+ item_id,
+ item_type,
)
- .bind(notification_id)
- .bind(item_id)
- .bind(item_type)
.execute(db)
.await?;
@@ -6919,7 +6919,7 @@ const DOC_D: &str = "dddddddd-dddd-dddd-dddd-dddddddddddd";
/// from [email protected], and point doc D's Companies property at `company`.
async fn seed_crm_document_associations(db: &PgPool, company: Uuid) -> anyhow::Result<()> {
let mut tx = db.begin().await?;
- sqlx::query("SET LOCAL session_replication_role = 'replica'")
+ sqlx::raw_sql("SET LOCAL session_replication_role = 'replica'")
.execute(&mut *tx)
.await?;
let link = Uuid::now_v7();
@@ -6929,50 +6929,52 @@ async fn seed_crm_document_associations(db: &PgPool, company: Uuid) -> anyhow::R
(vendor, "[email protected]"),
(other, "[email protected]"),
] {
- sqlx::query("INSERT INTO email_contacts (id, link_id, email_address) VALUES ($1, $2, $3)")
- .bind(id)
- .bind(link)
- .bind(address)
- .execute(&mut *tx)
- .await?;
+ sqlx::query!(
+ "INSERT INTO email_contacts (id, link_id, email_address) VALUES ($1, $2, $3)",
+ id,
+ link,
+ address,
+ )
+ .execute(&mut *tx)
+ .await?;
}
let to_acme = Uuid::parse_str("ea000001-0000-0000-0000-000000000099")?;
let from_globex = Uuid::now_v7();
for (message, sender) in [(to_acme, me), (from_globex, other)] {
- sqlx::query(
+ sqlx::query!(
"INSERT INTO email_messages (id, thread_id, link_id, from_contact_id) VALUES ($1, $2, $3, $4)",
+ message,
+ Uuid::now_v7(),
+ link,
+ sender,
)
- .bind(message)
- .bind(Uuid::now_v7())
- .bind(link)
- .bind(sender)
.execute(&mut *tx)
.await?;
}
- sqlx::query(
+ sqlx::query!(
"INSERT INTO email_message_recipients (message_id, contact_id, recipient_type) VALUES ($1, $2, 'TO')",
+ to_acme,
+ vendor,
)
- .bind(to_acme)
- .bind(vendor)
.execute(&mut *tx)
.await?;
- sqlx::query(
+ sqlx::query!(
"UPDATE email_attachments SET message_id = $1 WHERE id = 'ea000001-0000-0000-0000-000000000002'",
+ from_globex,
)
- .bind(from_globex)
.execute(&mut *tx)
.await?;
- sqlx::query(
+ sqlx::query!(
r#"INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)
VALUES ($1, $2, 'DOCUMENT', $3, $4)"#,
+ Uuid::now_v7(),
+ DOC_D,
+ SystemPropertyKey::COMPANIES_UUID,
+ serde_json::json!({
+ "type": "EntityReference",
+ "value": [{ "entity_type": "COMPANY", "entity_id": company.to_string() }]
+ }),
)
- .bind(Uuid::now_v7())
- .bind(DOC_D)
- .bind(SystemPropertyKey::COMPANIES_UUID)
- .bind(serde_json::json!({
- "type": "EntityReference",
- "value": [{ "entity_type": "COMPANY", "entity_id": company.to_string() }]
- }))
.execute(&mut *tx)
.await?;
tx.commit().await?;
diff --git a/crates/soup/src/outbound/pg_soup_repo/initiative/test.rs b/crates/soup/src/outbound/pg_soup_repo/initiative/test.rs
index c0c0b41e8c..e04710e206 100644
--- a/crates/soup/src/outbound/pg_soup_repo/initiative/test.rs
+++ b/crates/soup/src/outbound/pg_soup_repo/initiative/test.rs
@@ -155,6 +155,10 @@ async fn initiative_listing_and_candidate_gate_share_access_rules(
]
);
+ #[expect(
+ clippy::disallowed_methods,
+ reason = "checks the gate SQL that initiative_gate generates"
+ )]
let gated: Vec<Uuid> = sqlx::query_scalar(&format!(
r#"WITH user_source_ids AS (
SELECT cp.channel_id::text AS source_id FROM comms_channel_participants cp
diff --git a/crates/soup/src/outbound/pg_soup_repo/notified/test.rs b/crates/soup/src/outbound/pg_soup_repo/notified/test.rs
index 809811399c..ada139f42f 100644
--- a/crates/soup/src/outbound/pg_soup_repo/notified/test.rs
+++ b/crates/soup/src/outbound/pg_soup_repo/notified/test.rs
@@ -612,7 +612,7 @@ async fn seed_agent_sessions(pool: &Pool<Postgres>) -> anyhow::Result<(Uuid, Uui
let mine = Uuid::from_u128(0xa5e5_0001);
let theirs = Uuid::from_u128(0xa5e5_0002);
for (id, owner) in [(mine, USER_1), (theirs, USER_2)] {
- sqlx::query(
+ sqlx::query!(
r#"
INSERT INTO agent_session (
id, owner_id, bot_id, model, harness, repo_url, workspace, name,
@@ -621,20 +621,20 @@ async fn seed_agent_sessions(pool: &Pool<Postgres>) -> anyhow::Result<(Uuid, Uui
VALUES ($1, $2, $3, 'model', 'harness', NULL, '/workspace', 'Fix the flaky test',
'event', 'acp_ready', '2024-06-01 09:00:00+00', '2024-06-01 09:00:00+00')
"#,
+ id,
+ owner,
+ Uuid::from_u128(0xa9e7),
)
- .bind(id)
- .bind(owner)
- .bind(Uuid::from_u128(0xa9e7))
.execute(pool)
.await?;
- sqlx::query(
+ sqlx::query!(
r#"
INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level)
VALUES ($1, 'agent_session', $2, 'user', 'owner')
"#,
+ id,
+ owner,
)
- .bind(id)
- .bind(owner)
.execute(pool)
.await?;
}
@@ -642,24 +642,24 @@ async fn seed_agent_sessions(pool: &Pool<Postgres>) -> anyhow::Result<(Uuid, Uui
// about a session they have no access to must never surface.
for (index, session) in [(0x51u128, mine), (0x52u128, theirs)] {
let notification_id = Uuid::from_u128(index);
- sqlx::query(
+ sqlx::query!(
r#"
INSERT INTO notification ("id", "notification_event_type", "event_item_id", "event_item_type", "service_sender", "created_at", "metadata")
VALUES ($1, 'agent_session_settled', $2, 'agent_session', 'test', '2024-06-01 10:21:00', '{}')
"#,
+ notification_id,
+ session.to_string(),
)
- .bind(notification_id)
- .bind(session.to_string())
.execute(pool)
.await?;
- sqlx::query(
+ sqlx::query!(
r#"
INSERT INTO user_notification ("user_id", "notification_id", "created_at", "sent", "state")
VALUES ($1, $2, '2024-06-01 10:21:00', TRUE, 'unseen')
"#,
+ USER_1,
+ notification_id,
)
- .bind(USER_1)
- .bind(notification_id)
.execute(pool)
.await?;
}
diff --git a/crates/soup/src/outbound/pg_soup_repo/notified/test/explain.rs b/crates/soup/src/outbound/pg_soup_repo/notified/test/explain.rs
index 7ecba7806c..e7ed20cfa8 100644
--- a/crates/soup/src/outbound/pg_soup_repo/notified/test/explain.rs
+++ b/crates/soup/src/outbound/pg_soup_repo/notified/test/explain.rs
@@ -9,6 +9,10 @@ const PAGE_SIZE: i64 = 100;
// Both alternatives use the production query's bindings and access scopes.
// The SQL is generated from AST gates, so this cannot use a static SQLx macro.
+#[expect(
+ clippy::disallowed_methods,
+ reason = "binds SQL generated from AST gates"
+)]
fn bind_query(sql: &str) -> Query<'_, Postgres, PgArguments> {
let links = vec![Uuid::parse_str(LINK_1).unwrap()];
let sources = sources();