test(triggers): mirror the app_id-not-null inbound guard in the mock (review)
Adversarial review NIT: the #[cfg(test)] InMemoryTriggerRepo's email_inbound_target `.expect()`s app_id, which would panic if a future unit test fetched a group-owned email TEMPLATE. Filter `app_id.is_some()` like the production query's `AND t.app_id IS NOT NULL` so the mock stays faithful. Test-only; no production change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1027,9 +1027,12 @@ mod tests {
|
|||||||
) -> Result<Option<EmailInboundTarget>, TriggerRepoError> {
|
) -> Result<Option<EmailInboundTarget>, TriggerRepoError> {
|
||||||
let g = self.inner.lock().await;
|
let g = self.inner.lock().await;
|
||||||
Ok(g.get(&trigger_id)
|
Ok(g.get(&trigger_id)
|
||||||
.filter(|t| t.kind == TriggerKind::Email)
|
// Mirror the production guard (`email_inbound_target` filters
|
||||||
|
// `AND t.app_id IS NOT NULL`): a group-owned email TEMPLATE is
|
||||||
|
// never a valid inbound target.
|
||||||
|
.filter(|t| t.kind == TriggerKind::Email && t.app_id.is_some())
|
||||||
.map(|t| EmailInboundTarget {
|
.map(|t| EmailInboundTarget {
|
||||||
app_id: t.app_id.expect("email trigger is app-owned"),
|
app_id: t.app_id.expect("filtered to app-owned above"),
|
||||||
script_id: t.script_id,
|
script_id: t.script_id,
|
||||||
enabled: t.enabled,
|
enabled: t.enabled,
|
||||||
dispatch_mode: t.dispatch_mode,
|
dispatch_mode: t.dispatch_mode,
|
||||||
|
|||||||
Reference in New Issue
Block a user