mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 00:47:53 +00:00
wip "complex models"
This commit is contained in:
1 parent
361bfed6d6
commit
8931c7175a
3 files changed
+35
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,34 @@
|
||||
pub mod event_match_predicate;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum EventMatchPredicate {
|
||||
BitsCheermoteNameExactMatch {
|
||||
cheermote_name: String,
|
||||
},
|
||||
BitsSpendThreshold {
|
||||
minimum_bits_spent: u32,
|
||||
},
|
||||
ChannelPointsRewardNameExactMatch {
|
||||
reward_name: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::complex_models::EventMatchPredicate;
|
||||
|
||||
#[test]
|
||||
fn bits_cheermote_name_exact_match() {
|
||||
let rust_value = EventMatchPredicate::BitsCheermoteNameExactMatch {
|
||||
cheermote_name: "Cheer1".to_string()
|
||||
};
|
||||
let json = "{\"bits_cheermote_name_exact_match\":{\"cheermote_name\":\"Cheer1\"}}";
|
||||
|
||||
let converted_to_json= serde_json::to_string(&rust_value).unwrap();
|
||||
assert_eq!(&converted_to_json, json);
|
||||
|
||||
let converted_from_json : EventMatchPredicate = serde_json::from_str(json).unwrap();
|
||||
assert_eq!(&converted_from_json, &rust_value);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ pub const RESERVED_USERNAMES : &'static str = include_str!("../../../../db/reser
|
||||
pub const RESERVED_SUBSTRINGS : &'static str = include_str!("../../../../db/reserved_usernames_including.txt");
|
||||
|
||||
pub mod common_env;
|
||||
pub mod complex_models;
|
||||
pub mod http_clients;
|
||||
pub mod http_server;
|
||||
pub mod routes;
|
||||
|
||||
Reference in new issue
Block a user