MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / before_after_instead_of_coexist

Function before_after_instead_of_coexist

nodedb/tests/trigger_execution.rs:549–588  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

547
548#[test]
549fn before_after_instead_of_coexist() {
550 let reg = TriggerRegistry::new();
551 reg.register(make_before_trigger("validate", "orders", DmlEvent::Insert));
552 reg.register(make_instead_of_trigger(
553 "redirect",
554 "orders",
555 DmlEvent::Insert,
556 ));
557 reg.register(make_trigger_full(
558 "audit",
559 "orders",
560 TriggerTiming::After,
561 true,
562 false,
563 false,
564 TriggerExecutionMode::Async,
565 TriggerGranularity::Row,
566 TriggerSecurity::Invoker,
567 ));
568
569 let all = reg.get_matching(1, "orders", DmlEvent::Insert);
570 assert_eq!(all.len(), 3);
571
572 let before_count = all
573 .iter()
574 .filter(|t| t.timing == TriggerTiming::Before)
575 .count();
576 let after_count = all
577 .iter()
578 .filter(|t| t.timing == TriggerTiming::After)
579 .count();
580 let instead_count = all
581 .iter()
582 .filter(|t| t.timing == TriggerTiming::InsteadOf)
583 .count();
584
585 assert_eq!(before_count, 1);
586 assert_eq!(after_count, 1);
587 assert_eq!(instead_count, 1);
588}
589
590// ---------------------------------------------------------------------------
591// Priority ordering across timing types

Callers

nothing calls this directly

Calls 7

make_before_triggerFunction · 0.85
make_instead_of_triggerFunction · 0.85
make_trigger_fullFunction · 0.85
get_matchingMethod · 0.80
registerMethod · 0.45
countMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected