fix(mysql): correct Capabilities assertions in unit tests

This commit is contained in:
Austin Bonander 2024-08-21 15:12:26 -07:00
parent 01428ff643
commit 3a41288b84
2 changed files with 18 additions and 12 deletions

View file

@ -81,9 +81,14 @@ fn test_decode_auth_switch_cleartext_disabled() {
let e = AuthSwitchRequest::decode_with(AUTH_SWITCH_CLEARTEXT.into(), false).unwrap_err();
assert_eq!(
e.to_string(),
"encountered unexpected or invalid data: mysql_cleartext_plugin disabled"
let e_str = e.to_string();
let expected = "encountered unexpected or invalid data: mysql_cleartext_plugin disabled";
assert!(
// Don't want to assert the full string since it contains the module path now.
e_str.starts_with(expected),
"expected error string to start with {expected:?}, got {e_str:?}"
);
}

View file

@ -94,11 +94,12 @@ impl ProtocolDecode<'_> for Handshake {
fn test_decode_handshake_mysql_8_0_18() {
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";
let mut p = Handshake::decode(HANDSHAKE_MYSQL_8_0_18.into()).unwrap();
let p = Handshake::decode(HANDSHAKE_MYSQL_8_0_18.into()).unwrap();
assert_eq!(p.protocol_version, 10);
p.server_capabilities.toggle(
assert_eq!(
p.server_capabilities,
Capabilities::MYSQL
| Capabilities::FOUND_ROWS
| Capabilities::LONG_FLAG
@ -128,8 +129,6 @@ fn test_decode_handshake_mysql_8_0_18() {
| Capabilities::REMEMBER_OPTIONS,
);
assert!(p.server_capabilities.is_empty());
assert_eq!(p.server_default_collation, 255);
assert!(p.status.contains(Status::SERVER_STATUS_AUTOCOMMIT));
@ -148,7 +147,7 @@ fn test_decode_handshake_mysql_8_0_18() {
fn test_decode_handshake_mariadb_10_4_7() {
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";
let mut p = Handshake::decode(HANDSHAKE_MARIA_DB_10_4_7.into()).unwrap();
let p = Handshake::decode(HANDSHAKE_MARIA_DB_10_4_7.into()).unwrap();
assert_eq!(p.protocol_version, 10);
@ -157,7 +156,8 @@ fn test_decode_handshake_mariadb_10_4_7() {
"5.5.5-10.4.7-MariaDB-1:10.4.7+maria~bionic"
);
p.server_capabilities.toggle(
assert_eq!(
p.server_capabilities,
Capabilities::FOUND_ROWS
| Capabilities::LONG_FLAG
| Capabilities::CONNECT_WITH_DB
@ -179,11 +179,12 @@ fn test_decode_handshake_mariadb_10_4_7() {
| Capabilities::CAN_HANDLE_EXPIRED_PASSWORDS
| Capabilities::SESSION_TRACK
| Capabilities::DEPRECATE_EOF
| Capabilities::REMEMBER_OPTIONS,
| Capabilities::REMEMBER_OPTIONS
| Capabilities::MARIADB_CLIENT_PROGRESS
| Capabilities::MARIADB_CLIENT_MULTI
| Capabilities::MARIADB_CLIENT_STMT_BULK_OPERATIONS
);
assert!(p.server_capabilities.is_empty());
assert_eq!(p.server_default_collation, 8);
assert!(p.status.contains(Status::SERVER_STATUS_AUTOCOMMIT));
assert!(matches!(