Skip to content

Commit 05361bc

Browse files
committed
Tidy up test
Tidy up test by using `Result::expect_err` where appropriate, and other minor cleanups.
1 parent 868dae1 commit 05361bc

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/main.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,25 +209,25 @@ fn it_connects_tls_both() {
209209
#[test]
210210
fn it_does_not_connect_tls_client_only() {
211211
// Client requesting tls fails as expected when server does not support it.
212-
match TestingShim::new(
212+
213+
let e = TestingShim::new(
213214
|_, _| unreachable!(),
214215
|_| unreachable!(),
215216
|_, _, _| unreachable!(),
216217
|_, _| unreachable!(),
217218
)
218219
.with_client_tls()
219220
.test_with_result(|_| {})
220-
{
221-
Ok(()) => {
222-
panic!("client should not have connected")
223-
}
224-
Err(e) => match e.downcast_ref::<mysql::Error>() {
225-
Some(mysql::Error::DriverError(DriverError::TlsNotSupported)) => {
226-
// this is what we expect.
227-
}
228-
_ => panic!("unexpected error {}", e),
229-
},
230-
}
221+
.expect_err("client should not have connected");
222+
223+
assert!(
224+
matches!(
225+
e.downcast_ref::<mysql::Error>(),
226+
Some(mysql::Error::DriverError(DriverError::TlsNotSupported))
227+
),
228+
"unexpected error {:?}",
229+
e
230+
);
231231
}
232232

233233
#[test]

0 commit comments

Comments
 (0)