Remove redundant uses of format!()
This commit is contained in:
parent
af6ef9eec2
commit
a8d6df4e31
3 changed files with 45 additions and 42 deletions
|
@ -661,16 +661,16 @@ mod test {
|
|||
#[allow(unused)]
|
||||
fn test_config() -> Config {
|
||||
Config {
|
||||
owners: vec![format!("test")],
|
||||
nickname: Some(format!("test")),
|
||||
username: Some(format!("test")),
|
||||
realname: Some(format!("test")),
|
||||
owners: vec!["test".to_string()],
|
||||
nickname: Some("test".to_string()),
|
||||
username: Some("test".to_string()),
|
||||
realname: Some("test".to_string()),
|
||||
password: Some(String::new()),
|
||||
umodes: Some(format!("+BR")),
|
||||
server: Some(format!("irc.test.net")),
|
||||
umodes: Some("+BR".to_string()),
|
||||
server: Some("irc.test.net".to_string()),
|
||||
port: Some(6667),
|
||||
encoding: Some(format!("UTF-8")),
|
||||
channels: vec![format!("#test"), format!("#test2")],
|
||||
encoding: Some("UTF-8".to_string()),
|
||||
channels: vec!["#test".to_string(), "#test2".to_string()],
|
||||
|
||||
..Default::default()
|
||||
}
|
||||
|
@ -679,7 +679,7 @@ mod test {
|
|||
#[test]
|
||||
fn is_owner() {
|
||||
let cfg = Config {
|
||||
owners: vec![format!("test"), format!("test2")],
|
||||
owners: vec!["test".to_string(), "test2".to_string()],
|
||||
..Default::default()
|
||||
};
|
||||
assert!(cfg.is_owner("test"));
|
||||
|
@ -692,7 +692,7 @@ mod test {
|
|||
let cfg = Config {
|
||||
options: {
|
||||
let mut map = HashMap::new();
|
||||
map.insert(format!("testing"), format!("test"));
|
||||
map.insert("testing".to_string(), "test".to_string());
|
||||
map
|
||||
},
|
||||
..Default::default()
|
||||
|
|
|
@ -248,7 +248,7 @@ mod test {
|
|||
fn create_user() {
|
||||
let user = User::new("~owner");
|
||||
let exp = User {
|
||||
nickname: format!("owner"),
|
||||
nickname: "owner".to_string(),
|
||||
username: None,
|
||||
hostname: None,
|
||||
highest_access_level: Owner,
|
||||
|
@ -263,7 +263,7 @@ mod test {
|
|||
fn create_user_complex() {
|
||||
let user = User::new("~&+user");
|
||||
let exp = User {
|
||||
nickname: format!("user"),
|
||||
nickname: "user".to_string(),
|
||||
username: None,
|
||||
hostname: None,
|
||||
highest_access_level: Owner,
|
||||
|
|
|
@ -1114,12 +1114,12 @@ mod test {
|
|||
|
||||
pub fn test_config() -> Config {
|
||||
Config {
|
||||
owners: vec![format!("test")],
|
||||
nickname: Some(format!("test")),
|
||||
alt_nicks: vec![format!("test2")],
|
||||
server: Some(format!("irc.test.net")),
|
||||
channels: vec![format!("#test"), format!("#test2")],
|
||||
user_info: Some(format!("Testing.")),
|
||||
owners: vec!["test".to_string()],
|
||||
nickname: Some("test".to_string()),
|
||||
alt_nicks: vec!["test2".to_string()],
|
||||
server: Some("irc.test.net".to_string()),
|
||||
channels: vec!["#test".to_string(), "#test2".to_string()],
|
||||
user_info: Some("Testing.".to_string()),
|
||||
use_mock_connection: true,
|
||||
..Default::default()
|
||||
}
|
||||
|
@ -1180,8 +1180,8 @@ mod test {
|
|||
let value = ":irc.test.net 376 test :End of /MOTD command.\r\n";
|
||||
let mut client = Client::from_config(Config {
|
||||
mock_initial_value: Some(value.to_owned()),
|
||||
nick_password: Some(format!("password")),
|
||||
channels: vec![format!("#test"), format!("#test2")],
|
||||
nick_password: Some("password".to_string()),
|
||||
channels: vec!["#test".to_string(), "#test2".to_string()],
|
||||
..test_config()
|
||||
})
|
||||
.await?;
|
||||
|
@ -1199,11 +1199,11 @@ mod test {
|
|||
let value = ":irc.test.net 376 test :End of /MOTD command\r\n";
|
||||
let mut client = Client::from_config(Config {
|
||||
mock_initial_value: Some(value.to_owned()),
|
||||
nickname: Some(format!("test")),
|
||||
channels: vec![format!("#test"), format!("#test2")],
|
||||
nickname: Some("test".to_string()),
|
||||
channels: vec!["#test".to_string(), "#test2".to_string()],
|
||||
channel_keys: {
|
||||
let mut map = HashMap::new();
|
||||
map.insert(format!("#test2"), format!("password"));
|
||||
map.insert("#test2".to_string(), "password".to_string());
|
||||
map
|
||||
},
|
||||
..test_config()
|
||||
|
@ -1223,10 +1223,10 @@ mod test {
|
|||
:irc.test.net 376 test2 :End of /MOTD command.\r\n";
|
||||
let mut client = Client::from_config(Config {
|
||||
mock_initial_value: Some(value.to_owned()),
|
||||
nickname: Some(format!("test")),
|
||||
alt_nicks: vec![format!("test2")],
|
||||
nick_password: Some(format!("password")),
|
||||
channels: vec![format!("#test"), format!("#test2")],
|
||||
nickname: Some("test".to_string()),
|
||||
alt_nicks: vec!["test2".to_string()],
|
||||
nick_password: Some("password".to_string()),
|
||||
channels: vec!["#test".to_string(), "#test2".to_string()],
|
||||
should_ghost: true,
|
||||
..test_config()
|
||||
})
|
||||
|
@ -1246,12 +1246,12 @@ mod test {
|
|||
:irc.test.net 376 test2 :End of /MOTD command.\r\n";
|
||||
let mut client = Client::from_config(Config {
|
||||
mock_initial_value: Some(value.to_owned()),
|
||||
nickname: Some(format!("test")),
|
||||
alt_nicks: vec![format!("test2")],
|
||||
nick_password: Some(format!("password")),
|
||||
channels: vec![format!("#test"), format!("#test2")],
|
||||
nickname: Some("test".to_string()),
|
||||
alt_nicks: vec!["test2".to_string()],
|
||||
nick_password: Some("password".to_string()),
|
||||
channels: vec!["#test".to_string(), "#test2".to_string()],
|
||||
should_ghost: true,
|
||||
ghost_sequence: Some(vec![format!("RECOVER"), format!("RELEASE")]),
|
||||
ghost_sequence: Some(vec!["RECOVER".to_string(), "RELEASE".to_string()]),
|
||||
..test_config()
|
||||
})
|
||||
.await?;
|
||||
|
@ -1270,9 +1270,9 @@ mod test {
|
|||
let value = ":irc.test.net 376 test :End of /MOTD command.\r\n";
|
||||
let mut client = Client::from_config(Config {
|
||||
mock_initial_value: Some(value.to_owned()),
|
||||
nickname: Some(format!("test")),
|
||||
umodes: Some(format!("+B")),
|
||||
channels: vec![format!("#test"), format!("#test2")],
|
||||
nickname: Some("test".to_string()),
|
||||
umodes: Some("+B".to_string()),
|
||||
channels: vec!["#test".to_string(), "#test2".to_string()],
|
||||
..test_config()
|
||||
})
|
||||
.await?;
|
||||
|
@ -1319,7 +1319,7 @@ mod test {
|
|||
async fn send() -> Result<()> {
|
||||
let mut client = Client::from_config(test_config()).await?;
|
||||
assert!(client
|
||||
.send(PRIVMSG(format!("#test"), format!("Hi there!")))
|
||||
.send(PRIVMSG("#test".to_string(), "Hi there!".to_string()))
|
||||
.is_ok());
|
||||
client.stream()?.collect().await?;
|
||||
assert_eq!(
|
||||
|
@ -1333,7 +1333,10 @@ mod test {
|
|||
async fn send_no_newline_injection() -> Result<()> {
|
||||
let mut client = Client::from_config(test_config()).await?;
|
||||
assert!(client
|
||||
.send(PRIVMSG(format!("#test"), format!("Hi there!\r\nJOIN #bad")))
|
||||
.send(PRIVMSG(
|
||||
"#test".to_string(),
|
||||
"Hi there!\r\nJOIN #bad".to_string()
|
||||
))
|
||||
.is_ok());
|
||||
client.stream()?.collect().await?;
|
||||
assert_eq!(
|
||||
|
@ -1391,7 +1394,7 @@ mod test {
|
|||
assert_eq!(client.list_channels(), Some(vec!["#test".to_owned()]));
|
||||
// we ignore the result, as soon as we queue an outgoing message we
|
||||
// update client state, regardless if the queue is available or not.
|
||||
let _ = client.send(PART(format!("#test"), None));
|
||||
let _ = client.send(PART("#test".to_string(), None));
|
||||
assert_eq!(client.list_channels(), Some(vec![]));
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1520,8 +1523,8 @@ mod test {
|
|||
let value = ":test!test@test PRIVMSG #test :\u{001}\r\n";
|
||||
let mut client = Client::from_config(Config {
|
||||
mock_initial_value: Some(value.to_owned()),
|
||||
nickname: Some(format!("test")),
|
||||
channels: vec![format!("#test"), format!("#test2")],
|
||||
nickname: Some("test".to_string()),
|
||||
channels: vec!["#test".to_string(), "#test2".to_string()],
|
||||
..test_config()
|
||||
})
|
||||
.await?;
|
||||
|
@ -1664,8 +1667,8 @@ mod test {
|
|||
#[tokio::test]
|
||||
async fn identify_with_password() -> Result<()> {
|
||||
let mut client = Client::from_config(Config {
|
||||
nickname: Some(format!("test")),
|
||||
password: Some(format!("password")),
|
||||
nickname: Some("test".to_string()),
|
||||
password: Some("password".to_string()),
|
||||
..test_config()
|
||||
})
|
||||
.await?;
|
||||
|
|
Loading…
Reference in a new issue