diff options
author | alpaylan | 2021-04-14 01:49:24 +0300 |
---|---|---|
committer | alpaylan | 2021-04-14 01:49:24 +0300 |
commit | dfe92a1f61d1d56246d1680442042deffa0ea76c (patch) | |
tree | 1d439a5612d8d7b63e4eed82ee8dd06d9971503a | |
parent | dd039b4f21ee9cecbead24aedb51d0eb8b2e9495 (diff) | |
download | gradecoin-dfe92a1f61d1d56246d1680442042deffa0ea76c.tar.gz gradecoin-dfe92a1f61d1d56246d1680442042deffa0ea76c.tar.bz2 gradecoin-dfe92a1f61d1d56246d1680442042deffa0ea76c.zip |
start testing schema
-rw-r--r-- | src/schema.rs | 2 | ||||
-rw-r--r-- | tests/schema_tests.rs | 22 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/schema.rs b/src/schema.rs index 6719722..4d2b442 100644 --- a/src/schema.rs +++ b/src/schema.rs | |||
@@ -34,7 +34,7 @@ pub fn create_database() -> Db { | |||
34 | /// - `tha`: Transaction Hash, String (custom field) | 34 | /// - `tha`: Transaction Hash, String (custom field) |
35 | /// - `iat`: Issued At, Unix Time, epoch | 35 | /// - `iat`: Issued At, Unix Time, epoch |
36 | /// - `exp`: Expiration Time, epoch | 36 | /// - `exp`: Expiration Time, epoch |
37 | #[derive(Debug, Serialize, Deserialize)] | 37 | #[derive(Debug, Serialize, Deserialize, PartialEq)] |
38 | pub struct Claims { | 38 | pub struct Claims { |
39 | pub tha: String, | 39 | pub tha: String, |
40 | pub iat: usize, | 40 | pub iat: usize, |
diff --git a/tests/schema_tests.rs b/tests/schema_tests.rs index 5c28aed..8b07f72 100644 --- a/tests/schema_tests.rs +++ b/tests/schema_tests.rs | |||
@@ -1,9 +1,29 @@ | |||
1 | #[cfg(test)] | 1 | #[cfg(test)] |
2 | mod tests { | 2 | mod tests { |
3 | use gradecoin::schema::*; | ||
4 | use serde_json::error::Error; | ||
5 | use serde_test::{assert_tokens, Token}; | ||
3 | 6 | ||
4 | #[test] | 7 | #[test] |
5 | fn claims_serialize_correctly() { | 8 | fn claims_serialize_correctly() { |
6 | 9 | let claims = Claims { | |
10 | tha: "hashed_string".to_owned(), | ||
11 | iat: 0, | ||
12 | exp: 100, | ||
13 | }; | ||
14 | assert_tokens( | ||
15 | &claims, | ||
16 | &[ | ||
17 | Token::Struct{name: "Claims", len: 3}, | ||
18 | Token::String("tha"), | ||
19 | Token::String("hashed_string"), | ||
20 | Token::String("iat"), | ||
21 | Token::U64(0), | ||
22 | Token::String("exp"), | ||
23 | Token::U64(100), | ||
24 | Token::StructEnd, | ||
25 | ] | ||
26 | ) | ||
7 | } | 27 | } |
8 | 28 | ||
9 | #[test] | 29 | #[test] |