refactor(tvix/*/from_addr): improve test debuggability
If there's an unexpected test failure, print it out, rather than just saying something is false even though it should be true. Use .expect() for this, which displays the error if it failed. We can't use expect_err(), as our stores are not display'able, so use an assertion with a message there. Change-Id: I2d88861d979d107edc0717fbdb3cdac9a6bfc5e4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11091 Tested-by: BuildkiteCI Reviewed-by: Brian Olsen <me@griff.name> Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
parent
b0e5a932ec
commit
ef3f8936cb
3 changed files with 18 additions and 6 deletions
|
@ -115,7 +115,11 @@ mod tests {
|
|||
/// Correct scheme to connect to localhost over http, but with additional path, which is invalid.
|
||||
#[test_case("grpc+http://localhost/some-path", false; "grpc valid invalid host and path")]
|
||||
#[tokio::test]
|
||||
async fn test_from_addr_tokio(uri_str: &str, is_ok: bool) {
|
||||
assert_eq!(from_addr(uri_str).await.is_ok(), is_ok)
|
||||
async fn test_from_addr_tokio(uri_str: &str, exp_succeed: bool) {
|
||||
if exp_succeed {
|
||||
from_addr(uri_str).await.expect("should succeed");
|
||||
} else {
|
||||
assert!(from_addr(uri_str).await.is_err(), "should fail");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,11 @@ mod tests {
|
|||
/// Correct scheme to connect to localhost over http, but with additional path, which is invalid.
|
||||
#[test_case("grpc+http://localhost/some-path", false; "grpc valid invalid host and path")]
|
||||
#[tokio::test]
|
||||
async fn test_from_addr_tokio(uri_str: &str, is_ok: bool) {
|
||||
assert_eq!(from_addr(uri_str).await.is_ok(), is_ok)
|
||||
async fn test_from_addr_tokio(uri_str: &str, exp_succeed: bool) {
|
||||
if exp_succeed {
|
||||
from_addr(uri_str).await.expect("should succeed");
|
||||
} else {
|
||||
assert!(from_addr(uri_str).await.is_err(), "should fail");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ mod tests {
|
|||
/// Correct scheme to connect to localhost over http, but with additional path, which is invalid.
|
||||
#[test_case("grpc+http://localhost/some-path", false; "grpc valid invalid host and path")]
|
||||
#[tokio::test]
|
||||
async fn test_from_addr_tokio(uri_str: &str, is_ok: bool) {
|
||||
async fn test_from_addr_tokio(uri_str: &str, exp_succeed: bool) {
|
||||
let resp = from_addr(
|
||||
uri_str,
|
||||
gen_blob_service().into(),
|
||||
|
@ -182,6 +182,10 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
|
||||
assert_eq!(resp.is_ok(), is_ok);
|
||||
if exp_succeed {
|
||||
resp.expect("should succeed");
|
||||
} else {
|
||||
assert!(resp.is_err(), "should fail");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue