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

Function foreign_key_violation

nodedb-crdt/src/validator/tests.rs:75–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73
74#[test]
75fn foreign_key_violation() {
76 let (state, cs) = setup();
77 let validator = Validator::new(cs, 100);
78
79 let change = ProposedChange {
80 collection: "posts".into(),
81 row_id: "p1".into(),
82 surrogate: nodedb_types::Surrogate::ZERO,
83 fields: vec![("author_id".into(), LoroValue::String("u1".into()))],
84 };
85
86 match validator.validate(&state, &change) {
87 ValidationOutcome::Rejected(v) => {
88 assert_eq!(v[0].constraint_name, "posts_author_fk");
89 assert!(matches!(
90 v[0].hint,
91 CompensationHint::CreateReferencedRow { .. }
92 ));
93 }
94 _ => panic!("expected FK violation"),
95 }
96}
97
98#[test]
99fn foreign_key_passes_when_parent_exists() {

Callers

nothing calls this directly

Calls 2

setupFunction · 0.70
validateMethod · 0.45

Tested by

no test coverage detected