Skip to content

Commit

Permalink
Update page property by null
Browse files Browse the repository at this point in the history
  • Loading branch information
takassh committed Sep 22, 2024
1 parent 90464ff commit 51b9301
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build and Test

on:
push:
Expand Down
19 changes: 17 additions & 2 deletions src/endpoints/pages/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,30 @@ fn test_create_request() {
assert_eq!(result, actual.to_string())
}

#[test]
fn test_update_null_request() {
let mut properties = BTreeMap::new();
properties.insert("Date".to_string(), None);

let request = UpdatePagePropertiesRequest {
properties: properties,
..Default::default()
};

let result = serde_json::to_string_pretty(&request).unwrap();
let actual = include_str!("tests/update_null_request.json");
assert_eq!(result, actual.to_string())
}

#[test]
fn test_update_request() {
let mut properties = BTreeMap::new();
properties.insert(
"In stock".to_string(),
PageProperty::Checkbox {
Some(PageProperty::Checkbox {
id: None,
checkbox: true,
},
}),
);

let request = UpdatePagePropertiesRequest {
Expand Down
5 changes: 5 additions & 0 deletions src/endpoints/pages/tests/update_null_request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"properties": {
"Date": null
}
}
2 changes: 1 addition & 1 deletion src/endpoints/pages/update/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::objects::{
#[builder(setter(strip_option))]
#[builder(default)]
pub struct UpdatePagePropertiesRequest {
pub properties: BTreeMap<String, PageProperty>,
pub properties: BTreeMap<String, Option<PageProperty>>,
pub archived: Option<bool>,
pub icon: Option<Icon>,
pub cover: Option<File>,
Expand Down

0 comments on commit 51b9301

Please sign in to comment.