mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-09 19:41:32 +00:00
EventResponse::NotSet also needs to be empty enum for proper json
This commit is contained in:
1 parent
2c390ca20a
commit
b59d7af915
2 files changed
+18
-4
No files matched your search
@@ -14,11 +14,13 @@ pub enum EventMatchPredicate {
|
||||
|
||||
/// A predicate for a cheermote name without value, but with a minimum bits
|
||||
/// threshold. eg "Cheer", minimum=150 bits. Case insensitive.
|
||||
BitsCheermoteNameSpendThreshold {
|
||||
cheermote_name_prefix: String,
|
||||
/// Twitch also calls the leading part "prefix"
|
||||
BitsCheermotePrefixSpendThreshold {
|
||||
cheermote_prefix: String,
|
||||
minimum_bits_spent: u64,
|
||||
},
|
||||
|
||||
/// Spend a minimum amount of bits.
|
||||
BitsSpendThreshold {
|
||||
minimum_bits_spent: u64,
|
||||
},
|
||||
@@ -35,7 +37,6 @@ mod tests {
|
||||
#[test]
|
||||
fn not_set() {
|
||||
let rust_value = EventMatchPredicate::NotSet {};
|
||||
|
||||
let json = "{\"not_set\":{}}";
|
||||
|
||||
let converted_to_json= serde_json::to_string(&rust_value).unwrap();
|
||||
|
||||
@@ -4,7 +4,8 @@ use container_common::anyhow_result::AnyhowResult;
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum EventResponse {
|
||||
/// Default value
|
||||
NotSet,
|
||||
/// NB: This has an empty struct so it serializes as JSON and not a String!
|
||||
NotSet {},
|
||||
|
||||
/// Respond with a single TTS voice.
|
||||
TtsSingleVoice {
|
||||
@@ -21,6 +22,18 @@ pub enum EventResponse {
|
||||
mod tests {
|
||||
use crate::complex_models::event_responses::EventResponse;
|
||||
|
||||
#[test]
|
||||
fn not_set() {
|
||||
let rust_value = EventResponse::NotSet {};
|
||||
let json = "{\"not_set\":{}}";
|
||||
|
||||
let converted_to_json= serde_json::to_string(&rust_value).unwrap();
|
||||
assert_eq!(&converted_to_json, json);
|
||||
|
||||
let converted_from_json : EventResponse = serde_json::from_str(json).unwrap();
|
||||
assert_eq!(&converted_from_json, &rust_value);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tts_single_voice() {
|
||||
let rust_value = EventResponse::TtsSingleVoice {
|
||||
|
||||
Reference in new issue
Block a user