aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/resources/guild_create_features.json32
-rw-r--r--tests/test_channels.rs4
-rw-r--r--tests/test_create_embed.rs4
-rw-r--r--tests/test_deser.rs8
-rw-r--r--tests/test_formatters.rs4
5 files changed, 48 insertions, 4 deletions
diff --git a/tests/resources/guild_create_features.json b/tests/resources/guild_create_features.json
new file mode 100644
index 0000000..c522d7f
--- /dev/null
+++ b/tests/resources/guild_create_features.json
@@ -0,0 +1,32 @@
+{
+ "voice_states": [],
+ "verification_level": 2,
+ "unavailable": false,
+ "system_channel_id": "9876543210",
+ "splash": "abc",
+ "roles": [],
+ "region": "us-east",
+ "presences": [],
+ "owner_id": "157203992353570816",
+ "name": "abcdefg, hijklmnop, qrs, tuv, wx, y and z, now i know my abc's, next time won't you sing with me",
+ "mfa_level": 0,
+ "members": [],
+ "member_count": 585,
+ "large": true,
+ "joined_at": "2017-01-15T04:31:06.080000+00:00",
+ "id": "0123456789",
+ "icon": "def",
+ "features": [
+ "VIP_REGIONS",
+ "VERIFIED",
+ "VANITY_URL",
+ "INVITE_SPLASH"
+ ],
+ "explicit_content_filter": 0,
+ "emojis": [],
+ "default_message_notifications": 1,
+ "channels": [],
+ "application_id": null,
+ "afk_timeout": 300,
+ "afk_channel_id": null
+}
diff --git a/tests/test_channels.rs b/tests/test_channels.rs
index d871d5d..86523dc 100644
--- a/tests/test_channels.rs
+++ b/tests/test_channels.rs
@@ -1,12 +1,14 @@
#![cfg(feature = "model")]
+extern crate parking_lot;
extern crate serenity;
#[cfg(feature = "utils")]
mod utils {
+ use parking_lot::RwLock;
use serenity::model::*;
use std::collections::HashMap;
- use std::sync::{Arc, RwLock};
+ use std::sync::Arc;
fn group() -> Group {
Group {
diff --git a/tests/test_create_embed.rs b/tests/test_create_embed.rs
index 5c51dc6..dd84154 100644
--- a/tests/test_create_embed.rs
+++ b/tests/test_create_embed.rs
@@ -8,7 +8,7 @@ extern crate serenity;
use serde_json::Value;
use serenity::model::{Embed, EmbedField, EmbedImage};
use serenity::utils::builder::CreateEmbed;
-use serenity::utils::Colour;
+use serenity::utils::{self, Colour};
#[test]
fn test_from_embed() {
@@ -51,7 +51,7 @@ fn test_from_embed() {
.title("still a hakase")
.url("https://i.imgur.com/XfWpfCV.gif");
- let built = Value::Object(builder.0);
+ let built = Value::Object(utils::hashmap_to_json_map(builder.0));
let obj = json!({
"color": 0xFF0011,
diff --git a/tests/test_deser.rs b/tests/test_deser.rs
index 1024492..5288da2 100644
--- a/tests/test_deser.rs
+++ b/tests/test_deser.rs
@@ -165,3 +165,11 @@ fn webhooks_update() {
fn message_type_7() {
p!(MessageCreateEvent, "message_type_7");
}
+
+// Ensure string features are properly deserialized.
+//
+// Change made due to a new feature being added and not being in the enum.
+#[test]
+fn guild_features_deser() {
+ p!(GuildCreateEvent, "guild_create_features");
+}
diff --git a/tests/test_formatters.rs b/tests/test_formatters.rs
index b48c648..fbc60ca 100644
--- a/tests/test_formatters.rs
+++ b/tests/test_formatters.rs
@@ -1,3 +1,4 @@
+extern crate parking_lot;
extern crate serenity;
use serenity::model::*;
@@ -14,8 +15,9 @@ fn test_formatters() {
#[cfg(feature = "utils")]
#[test]
fn test_mention() {
+ use parking_lot::RwLock;
use serenity::utils::Colour;
- use std::sync::{Arc, RwLock};
+ use std::sync::Arc;
let channel = Channel::Guild(Arc::new(RwLock::new(GuildChannel {
bitrate: None,