This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new 0b890ea661 Improve test_auth error message when contains() fails
(#6657)
0b890ea661 is described below
commit 0b890ea661c9c7393bd06685c62e9cefe95a8cc9
Author: Piotr Findeisen <[email protected]>
AuthorDate: Thu Oct 31 19:36:48 2024 +0100
Improve test_auth error message when contains() fails (#6657)
---
arrow-flight/examples/flight_sql_server.rs | 53 ++++++++++++++++++++----------
1 file changed, 35 insertions(+), 18 deletions(-)
diff --git a/arrow-flight/examples/flight_sql_server.rs
b/arrow-flight/examples/flight_sql_server.rs
index 8c6c6e710b..657298b4a8 100644
--- a/arrow-flight/examples/flight_sql_server.rs
+++ b/arrow-flight/examples/flight_sql_server.rs
@@ -1006,30 +1006,36 @@ mod tests {
async fn test_auth() {
test_all_clients(|mut client| async move {
// no handshake
- assert!(client
- .prepare("select 1;".to_string(), None)
- .await
- .unwrap_err()
- .to_string()
- .contains("No authorization header"));
+ assert_contains(
+ client
+ .prepare("select 1;".to_string(), None)
+ .await
+ .unwrap_err()
+ .to_string(),
+ "No authorization header",
+ );
// Invalid credentials
- assert!(client
- .handshake("admin", "password2")
- .await
- .unwrap_err()
- .to_string()
- .contains("Invalid credentials"));
+ assert_contains(
+ client
+ .handshake("admin", "password2")
+ .await
+ .unwrap_err()
+ .to_string(),
+ "Invalid credentials",
+ );
// Invalid Tokens
client.handshake("admin", "password").await.unwrap();
client.set_token("wrong token".to_string());
- assert!(client
- .prepare("select 1;".to_string(), None)
- .await
- .unwrap_err()
- .to_string()
- .contains("invalid token"));
+ assert_contains(
+ client
+ .prepare("select 1;".to_string(), None)
+ .await
+ .unwrap_err()
+ .to_string(),
+ "invalid token",
+ );
client.clear_token();
@@ -1039,4 +1045,15 @@ mod tests {
})
.await
}
+
+ fn assert_contains(actual: impl AsRef<str>, searched_for: impl AsRef<str>)
{
+ let actual = actual.as_ref();
+ let searched_for = searched_for.as_ref();
+ assert!(
+ actual.contains(searched_for),
+ "Expected '{}' to contain '{}'",
+ actual,
+ searched_for
+ );
+ }
}