about summary refs log tree commit diff
path: root/tvix/castore/src/blobservice
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-03-03T15·44+0200
committerflokli <flokli@flokli.de>2024-03-03T16·54+0000
commitef3f8936cbb581e615e1e3c96f01ec9b42ceaa9e (patch)
tree06b7dd835747b422914b5fceaaa14f5b92e4fecb /tvix/castore/src/blobservice
parentb0e5a932ece4f94628cb44addc965799650b243e (diff)
refactor(tvix/*/from_addr): improve test debuggability r/7648
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>
Diffstat (limited to 'tvix/castore/src/blobservice')
-rw-r--r--tvix/castore/src/blobservice/from_addr.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/tvix/castore/src/blobservice/from_addr.rs b/tvix/castore/src/blobservice/from_addr.rs
index db221f05ab3b..1f73c802cc14 100644
--- a/tvix/castore/src/blobservice/from_addr.rs
+++ b/tvix/castore/src/blobservice/from_addr.rs
@@ -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");
+        }
     }
 }