1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use serde::{Deserialize, Serialize};

/// Information about a guild's vanity URL setting.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct VanityUrl {
    /// Code of the vanity URL.
    ///
    /// For example, in an invite of `discord.gg/applejack`, the code is
    /// `applejack`.
    pub code: String,
}

#[cfg(test)]
mod tests {
    use super::VanityUrl;
    use serde_test::Token;

    #[test]
    fn test_vanity_url() {
        let url = VanityUrl {
            code: "a".to_owned(),
        };
        serde_test::assert_tokens(
            &url,
            &[
                Token::Struct {
                    name: "VanityUrl",
                    len: 1,
                },
                Token::String("code"),
                Token::String("a"),
                Token::StructEnd,
            ],
        );
    }
}