From 7c59f9e43c233c668c2e9763c8af82b4f29efeb4 Mon Sep 17 00:00:00 2001 From: Danny Browning Date: Wed, 14 Feb 2024 10:40:28 -0700 Subject: [PATCH] fix: test --- src/lib.rs | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 68a3008..f51f3b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -588,7 +588,7 @@ pub mod tests { use crate::model_definition::{GetRootSchema, ModelAccountRelation, ModelDefinition}; use crate::query::{FilterQuery, OperationFilter}; use ceramic_event::{DidDocument, JwkSigner}; - use json_patch::ReplaceOperation; + use json_patch::{AddOperation, ReplaceOperation}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -657,22 +657,36 @@ pub mod tests { tokio::time::sleep(Duration::from_secs(1)).await; - let patch = json_patch::Patch(vec![json_patch::PatchOperation::Replace( - ReplaceOperation { - path: "/".to_string(), - value: serde_json::json!({ - "creator": ceramic.client().signer().id().id.clone(), - "radius": 1, - "red": 2, - "green": 3, - "blue": 4, - }), + let patch = json_patch::Patch(vec![json_patch::PatchOperation::Add( + AddOperation { + path: "/creator".to_string(), + value: serde_json::Value::String(ceramic.client().signer().id().id.clone()), }, + ), json_patch::PatchOperation::Add( + AddOperation { + path: "/radius".to_string(), + value: serde_json::Value::Number(serde_json::Number::from(1)), + } + ), json_patch::PatchOperation::Add( + AddOperation { + path: "/red".to_string(), + value: serde_json::Value::Number(serde_json::Number::from(2)), + } + ), json_patch::PatchOperation::Add( + AddOperation { + path: "/green".to_string(), + value: serde_json::Value::Number(serde_json::Number::from(3)), + } + ), json_patch::PatchOperation::Add( + AddOperation { + path: "/blue".to_string(), + value: serde_json::Value::Number(serde_json::Number::from(4)), + } )]); let post_resp = ceramic.update(&model, &stream_id, patch).await.unwrap(); assert_eq!(post_resp.stream_id, stream_id); let post_resp: Ball = serde_json::from_value(post_resp.state.unwrap().content).unwrap(); - assert_eq!(post_resp.red, 5); + assert_eq!(post_resp.red, 2); } #[tokio::test]