mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-12 04:37:44 +02:00
add patch error test
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
@@ -473,6 +473,30 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_patch_err() {
|
||||
let mut doc = json!({});
|
||||
|
||||
let patches = vec![
|
||||
PatchOperation::Standard(StandardPatchOperation::Add(json_patch::AddOperation {
|
||||
path: PointerBuf::from_tokens(["a"]),
|
||||
value: json!([]),
|
||||
})),
|
||||
PatchOperation::Standard(StandardPatchOperation::Add(json_patch::AddOperation {
|
||||
path: PointerBuf::from_tokens(["a", "b"]),
|
||||
value: json!(1),
|
||||
})),
|
||||
];
|
||||
|
||||
let res = apply(&mut doc, &patches);
|
||||
assert_eq!(
|
||||
res,
|
||||
Err(HulyPatchError::PatchError(String::from(
|
||||
"operation '/0' failed at path '/a/b': path is invalid"
|
||||
)))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialize_add_safe() {
|
||||
let patch = r#"{ "hop": "add", "path": "/a", "value": 1, "safe": true }"#;
|
||||
|
||||
Reference in New Issue
Block a user