aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-04-15 21:15:06 -0700
committerZeyla Hellyer <[email protected]>2017-04-19 14:53:32 -0700
commit269faf8773029e96d2f684bc7525914bcfc00c96 (patch)
tree2c8a4015d22736fa9538616b01bd24598509497b /src
parentImplement `From<&str> for ReactionType` (diff)
downloadserenity-269faf8773029e96d2f684bc7525914bcfc00c96.tar.xz
serenity-269faf8773029e96d2f684bc7525914bcfc00c96.zip
Add a test suite for event deserialization
Add a test suite for most of the events that can be easily procuced, and store them in static JSON files so the tests are ran on every build. The recent update to using serde{,_derive} for deserialization was a rough patch, as it was a large change which couldn't be fully tested at the time. By adding JSON files which are deserialized, this will produce a test suite that can be easily run on every new set of commits to prevent any backwards incompatible changes with regards to deserialization.
Diffstat (limited to 'src')
-rw-r--r--src/model/event.rs2
-rw-r--r--src/model/guild/partial_guild.rs3
2 files changed, 5 insertions, 0 deletions
diff --git a/src/model/event.rs b/src/model/event.rs
index e0f1993..db5a7c7 100644
--- a/src/model/event.rs
+++ b/src/model/event.rs
@@ -3,6 +3,7 @@
use serde::de::Error as DeError;
use serde_json::{self, Error as JsonError};
use std::collections::HashMap;
+use super::utils::deserialize_emojis;
use super::*;
use ::constants::{OpCode, VoiceOpCode};
use ::internal::prelude::*;
@@ -134,6 +135,7 @@ impl Deserialize for GuildDeleteEvent {
#[derive(Clone, Debug, Deserialize)]
pub struct GuildEmojisUpdateEvent {
+ #[serde(deserialize_with="deserialize_emojis")]
pub emojis: HashMap<EmojiId, Emoji>,
pub guild_id: GuildId,
}
diff --git a/src/model/guild/partial_guild.rs b/src/model/guild/partial_guild.rs
index 2be0ae2..8c1113b 100644
--- a/src/model/guild/partial_guild.rs
+++ b/src/model/guild/partial_guild.rs
@@ -1,3 +1,4 @@
+use super::super::utils::{deserialize_emojis, deserialize_roles};
use ::model::*;
use ::utils::builder::{EditGuild, EditMember, EditRole};
@@ -13,6 +14,7 @@ pub struct PartialGuild {
pub default_message_notifications: u64,
pub embed_channel_id: Option<ChannelId>,
pub embed_enabled: bool,
+ #[serde(deserialize_with="deserialize_emojis")]
pub emojis: HashMap<EmojiId, Emoji>,
pub features: Vec<Feature>,
pub icon: Option<String>,
@@ -20,6 +22,7 @@ pub struct PartialGuild {
pub name: String,
pub owner_id: UserId,
pub region: String,
+ #[serde(deserialize_with="deserialize_roles")]
pub roles: HashMap<RoleId, Role>,
pub splash: Option<String>,
pub verification_level: VerificationLevel,