Skip to content

Commit

Permalink
Merge pull request #213 from nrjais/210
Browse files Browse the repository at this point in the history
[Refactor] Remove matches dependency and use matches macro from std
  • Loading branch information
mehcode authored Mar 31, 2020
2 parents 8860980 + c29fc5c commit 8cb056c
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 14 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions sqlx-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,3 @@ version = "0.17.1"
optional = true
default-features = false
features = [ "pkg-config", "vcpkg", "bundled" ]

[dev-dependencies]
matches = "0.1.8"
5 changes: 2 additions & 3 deletions sqlx-core/src/mysql/protocol/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ impl Handshake {
#[cfg(test)]
mod tests {
use super::{AuthPlugin, Capabilities, Handshake, Status};
use matches::assert_matches;

const HANDSHAKE_MARIA_DB_10_4_7: &[u8] = b"\n5.5.5-10.4.7-MariaDB-1:10.4.7+maria~bionic\x00\x0b\x00\x00\x00t6L\\j\"dS\x00\xfe\xf7\x08\x02\x00\xff\x81\x15\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00U14Oph9\"<H5n\x00mysql_native_password\x00";
const HANDSHAKE_MYSQL_8_0_18: &[u8] = b"\n8.0.18\x00\x19\x00\x00\x00\x114aB0c\x06g\x00\xff\xff\xff\x02\x00\xff\xc7\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00tL\x03s\x0f[4\rl4. \x00caching_sha2_password\x00";
Expand Down Expand Up @@ -148,7 +147,7 @@ mod tests {

assert_eq!(p.server_default_collation, 255);
assert!(p.status.contains(Status::SERVER_STATUS_AUTOCOMMIT));
assert_matches!(p.auth_plugin, AuthPlugin::CachingSha2Password);
assert!(matches!(p.auth_plugin, AuthPlugin::CachingSha2Password));

assert_eq!(
&*p.auth_plugin_data,
Expand Down Expand Up @@ -196,7 +195,7 @@ mod tests {

assert_eq!(p.server_default_collation, 8);
assert!(p.status.contains(Status::SERVER_STATUS_AUTOCOMMIT));
assert_matches!(p.auth_plugin, AuthPlugin::MySqlNativePassword);
assert!(matches!(p.auth_plugin, AuthPlugin::MySqlNativePassword));

assert_eq!(
&*p.auth_plugin_data,
Expand Down
5 changes: 2 additions & 3 deletions sqlx-core/src/postgres/protocol/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ impl AuthenticationSaslContinue {
mod tests {
use super::Authentication;
use crate::postgres::protocol::authentication::AuthenticationMd5;
use matches::assert_matches;

const AUTH_OK: &[u8] = b"\0\0\0\0";
const AUTH_MD5: &[u8] = b"\0\0\0\x05\x93\x189\x98";
Expand All @@ -176,15 +175,15 @@ mod tests {
fn it_reads_auth_ok() {
let m = Authentication::read(AUTH_OK).unwrap();

assert_matches!(m, Authentication::Ok);
assert!(matches!(m, Authentication::Ok));
}

#[test]
fn it_reads_auth_md5_password() {
let m = Authentication::read(AUTH_MD5).unwrap();
let data = AuthenticationMd5::read(&AUTH_MD5[4..]).unwrap();

assert_matches!(m, Authentication::Md5Password);
assert!(matches!(m, Authentication::Md5Password));
assert_eq!(data.salt, [147, 24, 57, 152]);
}
}
3 changes: 1 addition & 2 deletions sqlx-core/src/postgres/protocol/ready_for_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ impl ReadyForQuery {
#[cfg(test)]
mod tests {
use super::{ReadyForQuery, TransactionStatus};
use matches::assert_matches;

const READY_FOR_QUERY: &[u8] = b"E";

#[test]
fn it_decodes_ready_for_query() {
let message = ReadyForQuery::read(READY_FOR_QUERY).unwrap();

assert_matches!(message.status, TransactionStatus::Error);
assert!(matches!(message.status, TransactionStatus::Error));
}
}
3 changes: 1 addition & 2 deletions sqlx-core/src/postgres/protocol/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ impl Response {
#[cfg(test)]
mod tests {
use super::{Response, Severity};
use matches::assert_matches;

const RESPONSE: &[u8] = b"SNOTICE\0VNOTICE\0C42710\0Mextension \"uuid-ossp\" already exists, \
skipping\0Fextension.c\0L1656\0RCreateExtension\0\0";
Expand All @@ -237,7 +236,7 @@ mod tests {
fn it_decodes_response() {
let message = Response::read(RESPONSE).unwrap();

assert_matches!(message.severity, Severity::Notice);
assert!(matches!(message.severity, Severity::Notice));
assert_eq!(&*message.code, "42710");
assert_eq!(&*message.file.unwrap(), "extension.c");
assert_eq!(message.line, Some(1656));
Expand Down

0 comments on commit 8cb056c

Please sign in to comment.