-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix User::avatar_url + add Id display tests
User::avatar_url was formatting the user's Id as a mention, rather than the inner u64.
- Loading branch information
Austin Hellyer
committed
Dec 15, 2016
1 parent
16bd765
commit 0708ccf
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
extern crate serenity; | ||
|
||
use serenity::model::*; | ||
|
||
#[test] | ||
fn test_formatters() { | ||
assert_eq!(format!("{}", ChannelId(1)), "<#1>"); | ||
assert_eq!(format!("{}", EmojiId(2)), "2"); | ||
assert_eq!(format!("{}", GuildId(3)), "3"); | ||
assert_eq!(format!("{}", RoleId(4)), "<@&4>"); | ||
assert_eq!(format!("{}", UserId(5)), "<@5>"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
extern crate serenity; | ||
|
||
use serenity::model::{User, UserId}; | ||
|
||
fn gen() -> User { | ||
User { | ||
id: UserId(210), | ||
avatar: Some("abc".to_owned()), | ||
bot: true, | ||
discriminator: "1432".to_owned(), | ||
name: "test".to_owned(), | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_core() { | ||
let mut user = gen(); | ||
|
||
assert!(user.avatar_url().unwrap().ends_with("/avatars/210/abc.jpg")); | ||
|
||
user.avatar = None; | ||
|
||
assert!(user.avatar_url().is_none()); | ||
} |