diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/tests.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/tests.rs b/src/tests.rs new file mode 100644 index 0000000..919ba01 --- /dev/null +++ b/src/tests.rs @@ -0,0 +1,20 @@ +#[cfg(test)] +mod tests { + use crate::validator::Validator; + use crate::models::Post; + use serde_json; + + #[test] + fn test_post_schemas_correspondence() { + let p = Post { + id: 0, + title: "Title".to_string(), + body: "Body".to_string(), + published: true, + hidden: false + }; + let v = Validator::from_file("schemas/post.json").unwrap(); + let json = serde_json::to_string(&p).unwrap(); + assert_eq!(v.check(&json), true); + } +} |