about summary refs log tree commit diff
path: root/tvix/castore/src
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-04-06T20·46+0300
committerflokli <flokli@flokli.de>2024-04-07T14·51+0000
commitc715b6d4486b2c9fc0e42b1d8e62004dc91868bd (patch)
tree6c81b6926baf4fe89ae82bea28c3944517aa66fd /tvix/castore/src
parent71fb99a2650280e6ec7c7d2543908c5a73d1b593 (diff)
refactor(tvix/castore/tonic): migrate to rstest r/7863
Change-Id: Ie088bf03c739bf64abf3432175362a8f92f501c2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11367
Tested-by: BuildkiteCI
Reviewed-by: picnoir picnoir <picnoir@alternativebit.fr>
Diffstat (limited to 'tvix/castore/src')
-rw-r--r--tvix/castore/src/tonic.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/tvix/castore/src/tonic.rs b/tvix/castore/src/tonic.rs
index 8ea417548ce9..4b65d6b028ef 100644
--- a/tvix/castore/src/tonic.rs
+++ b/tvix/castore/src/tonic.rs
@@ -87,31 +87,35 @@ impl From<tonic::transport::Error> for Error {
 #[cfg(test)]
 mod tests {
     use super::channel_from_url;
-    use test_case::test_case;
+    use rstest::rstest;
     use url::Url;
 
+    #[rstest]
     /// Correct scheme to connect to a unix socket.
-    #[test_case("grpc+unix:///path/to/somewhere", true; "grpc valid unix socket")]
+    #[case::valid_unix_socket("grpc+unix:///path/to/somewhere", true)]
     /// Connecting with wait-connect set to 0 succeeds, as that's the default.
-    #[test_case("grpc+unix:///path/to/somewhere?wait-connect=0", true; "grpc valid unix wait-connect=0")]
+    #[case::valid_unix_socket_wait_connect_0("grpc+unix:///path/to/somewhere?wait-connect=0", true)]
     /// Connecting with wait-connect set to 1 fails, as the path doesn't exist.
-    #[test_case("grpc+unix:///path/to/somewhere?wait-connect=1", false; "grpc valid unix wait-connect=1")]
+    #[case::valid_unix_socket_wait_connect_1(
+        "grpc+unix:///path/to/somewhere?wait-connect=1",
+        false
+    )]
     /// Correct scheme for unix socket, but setting a host too, which is invalid.
-    #[test_case("grpc+unix://host.example/path/to/somewhere", false; "grpc invalid unix socket and host")]
+    #[case::invalid_unix_socket_and_host("grpc+unix://host.example/path/to/somewhere", false)]
     /// Correct scheme to connect to localhost, with port 12345
-    #[test_case("grpc+http://[::1]:12345", true; "grpc valid IPv6 localhost port 12345")]
+    #[case::valid_ipv6_localhost_port_12345("grpc+http://[::1]:12345", true)]
     /// Correct scheme to connect to localhost over http, without specifying a port.
-    #[test_case("grpc+http://localhost", true; "grpc valid http host without port")]
+    #[case::valid_http_host_without_port("grpc+http://localhost", true)]
     /// Correct scheme to connect to localhost over http, without specifying a port.
-    #[test_case("grpc+https://localhost", true; "grpc valid https host without port")]
+    #[case::valid_https_host_without_port("grpc+https://localhost", true)]
     /// 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")]
+    #[case::invalid_host_and_path("grpc+http://localhost/some-path", false)]
     /// Connecting with wait-connect set to 0 succeeds, as that's the default.
-    #[test_case("grpc+http://localhost?wait-connect=0", true; "grpc valid host wait-connect=0")]
+    #[case::valid_host_wait_connect_0("grpc+http://localhost?wait-connect=0", true)]
     /// Connecting with wait-connect set to 1 fails, as the host doesn't exist.
-    #[test_case("grpc+http://nonexist.invalid?wait-connect=1", false; "grpc valid host wait-connect=1")]
+    #[case::valid_host_wait_connect_1_fails("grpc+http://nonexist.invalid?wait-connect=1", false)]
     #[tokio::test]
-    async fn test_from_addr_tokio(uri_str: &str, is_ok: bool) {
+    async fn test_from_addr_tokio(#[case] uri_str: &str, #[case] is_ok: bool) {
         let url = Url::parse(uri_str).expect("must parse");
         assert_eq!(channel_from_url(&url).await.is_ok(), is_ok)
     }