Skip to content

Commit

Permalink
Fix issues reported by clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
exul committed May 7, 2017
1 parent 64a25fc commit da74ecb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/bin/matrix-rocketchat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn run() -> Result<Listening> {
let config_path = matches.value_of("config").unwrap_or("config.yaml").to_string();
let config = Config::read_from_file(&config_path).chain_err(|| ErrorKind::ReadFileError(config_path))?;
let log_file_path = matches.value_of("log_file").unwrap_or("matrix-rocketchat.log");
let log = build_logger(&log_file_path);
let log = build_logger(log_file_path);
let threads = num_cpus::get() * 8;
Server::new(&config, log).run(threads)
}
Expand Down
22 changes: 14 additions & 8 deletions tests/admin_commands_connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ fn successfully_connect_rocketchat_server() {
receiver.recv_timeout(default_timeout()).unwrap();

let message_received_by_matrix = receiver.recv_timeout(default_timeout()).unwrap();
assert!(message_received_by_matrix.contains(&format!("You are connected to {}",
test.rocketchat_mock_url.clone().unwrap())));
let expected_message = format!("You are connected to {}", test.rocketchat_mock_url.clone().unwrap());
assert!(message_received_by_matrix.contains(&expected_message));

let connection = test.connection_pool.get().unwrap();
let rocketchat_server =
Expand Down Expand Up @@ -112,7 +112,8 @@ fn attempt_to_connect_to_a_non_rocketchat_server() {
receiver.recv_timeout(default_timeout()).unwrap();

let message_received_by_matrix = receiver.recv_timeout(default_timeout()).unwrap();
assert!(message_received_by_matrix.contains(&format!("No Rocket.Chat server found when querying {}", rocketchat_mock_url)));
let expected_message = format!("No Rocket.Chat server found when querying {}", rocketchat_mock_url);
assert!(message_received_by_matrix.contains(&expected_message));
}

#[test]
Expand Down Expand Up @@ -148,7 +149,9 @@ fn attempt_to_connect_to_a_server_with_the_correct_endpoint_but_an_incompatible_
receiver.recv_timeout(default_timeout()).unwrap();

let message_received_by_matrix = receiver.recv_timeout(default_timeout()).unwrap();
assert!(message_received_by_matrix.contains(&format!("No Rocket.Chat server found when querying {}/api/info (version information is missing from the response)", rocketchat_mock_url)));
let expected_message = format!("No Rocket.Chat server found when querying {}/api/info (version information is missing from the response)",
rocketchat_mock_url);
assert!(message_received_by_matrix.contains(&expected_message));
}


Expand All @@ -172,7 +175,8 @@ fn attempt_to_connect_to_non_existing_server() {
receiver.recv_timeout(default_timeout()).unwrap();

let message_received_by_matrix = receiver.recv_timeout(default_timeout()).unwrap();
assert!(message_received_by_matrix.contains(&format!("Could not reach Rocket.Chat server {}", rocketchat_mock_url)));
let expected_message = format!("Could not reach Rocket.Chat server {}", rocketchat_mock_url);
assert!(message_received_by_matrix.contains(&expected_message));
}

#[test]
Expand Down Expand Up @@ -202,8 +206,8 @@ fn connect_an_existing_server() {
receiver.recv_timeout(default_timeout()).unwrap();

let message_received_by_matrix = receiver.recv_timeout(default_timeout()).unwrap();
assert!(message_received_by_matrix.contains(&format!("You are connected to {}",
test.rocketchat_mock_url.clone().unwrap())));
let expected_message = format!("You are connected to {}", test.rocketchat_mock_url.clone().unwrap());
assert!(message_received_by_matrix.contains(&expected_message));
}

#[test]
Expand Down Expand Up @@ -234,7 +238,9 @@ fn attempt_to_connect_to_an_existing_server_with_a_token() {
receiver.recv_timeout(default_timeout()).unwrap();

let message_received_by_matrix = receiver.recv_timeout(default_timeout()).unwrap();
assert!(message_received_by_matrix.contains(&format!("The Rocket.Chat server {} is already connected, connect without a token if you want to connect to the server", test.rocketchat_mock_url.clone().unwrap())));
let expected_message = format!("The Rocket.Chat server {} is already connected, connect without a token if you want to connect to the server",
test.rocketchat_mock_url.clone().unwrap());
assert!(message_received_by_matrix.contains(&expected_message));
}

#[test]
Expand Down
3 changes: 2 additions & 1 deletion tests/admin_commands_help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ fn help_command_when_connected() {
receiver.recv_timeout(default_timeout()).unwrap();

let message_received_by_matrix = receiver.recv_timeout(default_timeout()).unwrap();
let expected_curl_command = format!("curl http://{}", test.as_listening.as_ref().unwrap().socket);
assert!(message_received_by_matrix.contains("You have to login before you can use the application service, there are two ways to do that"));
assert!(message_received_by_matrix.contains(&format!("curl http://{}", test.as_listening.as_ref().unwrap().socket)));
assert!(message_received_by_matrix.contains(&expected_curl_command));
}

#[test]
Expand Down
5 changes: 3 additions & 2 deletions tests/admin_commands_login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,9 @@ fn login_via_rest_api_with_a_user_that_has_no_connected_admin_room_for_the_rocke
&HashMap::new(),
None)
.unwrap();
assert!(response.contains(&format!("No admin room found that is connected to the Rocket.Chat server {}",
&test.rocketchat_mock_url.clone().unwrap())));
let expected_respones = format!("No admin room found that is connected to the Rocket.Chat server {}",
&test.rocketchat_mock_url.clone().unwrap());
assert!(response.contains(&expected_respones));
assert_eq!(status_code, status::NotFound);
}

Expand Down

0 comments on commit da74ecb

Please sign in to comment.