Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
dbcfd committed Feb 14, 2024
1 parent b7006b8 commit 7c59f9e
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 7c59f9e

Please sign in to comment.