aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-10-14 16:14:43 -0700
committerZeyla Hellyer <[email protected]>2017-10-14 16:14:43 -0700
commit78c6df9ed3640c097ef088519ec99a6a01796bfc (patch)
treea53aea0c11bbbc94941b99b55e831ac2e611dd0f /tests
parentUpdate to account for changes made in 0.4.1 (diff)
downloadserenity-78c6df9ed3640c097ef088519ec99a6a01796bfc.tar.xz
serenity-78c6df9ed3640c097ef088519ec99a6a01796bfc.zip
Change `features` fields to be a Vec<String>
When Discord adds new features, the Feature enum will not be able to serialize the new values until updated, causing the entire Guild deserialization to fail. Due to the fact that these features can be added at any time, the `features` vector on Guild and PartialGuild have been changed to be a `Vec<String>`. Upgrade path: Instead of matching on variants of Feature like so: ```rust use serenity::model::Feature; for feature in guild.features { if feature == Feature::VipRegions { // do work with this info } } ``` Instead opt to check the string name of the feature: ```rust for feature in guild.features { if feature == "VIP_REGIONS" { // do work with this info } } ```
Diffstat (limited to 'tests')
-rw-r--r--tests/resources/guild_create_features.json32
-rw-r--r--tests/test_deser.rs8
2 files changed, 40 insertions, 0 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_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");
+}