Skip to content

Commit

Permalink
Merge pull request #7 from Melvillian/melvillian/synced-from-null
Browse files Browse the repository at this point in the history
update SyncedBlockValue struct to handle original and synced form.
  • Loading branch information
takassh authored Oct 4, 2024
2 parents 07f5591 + 6b1ba1e commit b2a401f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/endpoints/blocks/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ fn test_delete_200() {
}

#[test]
fn test_link_mention_mention_deserialization() {
let result = serde_json::from_str::<Block>(include_str!(
"tests/link_mention_mention_deserialization.json"
));
fn test_deserialize_synced_from_block() {
let result = serde_json::from_str::<Vec<Block>>(include_str!("tests/synced_from_block.json"));
assert!(result.is_ok())
}
42 changes: 42 additions & 0 deletions src/endpoints/blocks/tests/synced_from_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"archived": false,
"created_by": {
"id": "5be127e8-c6d7-4a7b-a46d-a0eb3bc9d6af",
"object": "user"
},
"created_time": "2024-03-30T16:20:00.000Z",
"has_children": true,
"id": "3afef8a5-6870-453c-95b0-4f90c48b77ad",
"in_trash": false,
"last_edited_by": {
"id": "5be127e8-c6d7-4a7b-a46d-a0eb3bc9d6af",
"object": "user"
},
"last_edited_time": "2024-03-30T16:20:00.000Z",
"object": "block",
"parent": {
"page_id": "c870852e-d52d-4eb0-8618-a143adcad389",
"type": "page_id"
},
"synced_block": {
"synced_from": null
},
"type": "synced_block"
},
{
"object": "block",
"id": "block_id",
"created_time": "2021-11-17T22:17:00.000Z",
"last_edited_time": "2021-11-17T22:17:00.000Z",
"has_children": true,
"archived": false,
"type": "synced_block",
"synced_block": {
"synced_from": {
"type": "block_id",
"block_id": "3afef8a5-6870-453c-95b0-4f90c48b77ad"
}
}
}
]
2 changes: 1 addition & 1 deletion src/objects/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub struct QuoteValue {

#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)]
pub struct SyncedBlockValue {
pub synced_from: SyncedFrom,
pub synced_from: Option<SyncedFrom>,
#[serde(skip_serializing_if = "Option::is_none")]
pub children: Option<Vec<Block>>,
}
Expand Down

0 comments on commit b2a401f

Please sign in to comment.