From c772a786a967bed8625f59b5cceba871d2bde3c3 Mon Sep 17 00:00:00 2001 From: tottoto Date: Thu, 5 Jan 2023 04:19:28 +0900 Subject: [PATCH] chore: Refactor bootstrap test (#1216) * chore: Remove unnecessary conversions to string in bootstrap tests * chore: Simplify assertion in bootstrap tests --- tonic-health/tests/bootstrap.rs | 8 +++----- tonic-reflection/tests/bootstrap.rs | 8 +++----- tonic-types/tests/bootstrap.rs | 8 +++----- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/tonic-health/tests/bootstrap.rs b/tonic-health/tests/bootstrap.rs index bb3241a..f02dd2e 100644 --- a/tonic-health/tests/bootstrap.rs +++ b/tonic-health/tests/bootstrap.rs @@ -13,7 +13,7 @@ fn bootstrap() { .build_client(true) .build_server(true) .build_transport(false) - .out_dir(format!("{}", out_dir.display())) + .out_dir(&out_dir) .compile(iface_files, dirs) .unwrap(); @@ -21,11 +21,9 @@ fn bootstrap() { .arg("diff") .arg("--exit-code") .arg("--") - .arg(format!("{}", out_dir.display())) + .arg(&out_dir) .status() .unwrap(); - if !status.success() { - panic!("You should commit the protobuf files"); - } + assert!(status.success(), "You should commit the protobuf files"); } diff --git a/tonic-reflection/tests/bootstrap.rs b/tonic-reflection/tests/bootstrap.rs index 36fa8ea..66ee998 100644 --- a/tonic-reflection/tests/bootstrap.rs +++ b/tonic-reflection/tests/bootstrap.rs @@ -13,7 +13,7 @@ fn bootstrap() { .build_client(true) .build_server(true) .build_transport(false) - .out_dir(format!("{}", out_dir.display())) + .out_dir(&out_dir) .compile(iface_files, dirs) .unwrap(); @@ -21,11 +21,9 @@ fn bootstrap() { .arg("diff") .arg("--exit-code") .arg("--") - .arg(format!("{}", out_dir.display())) + .arg(&out_dir) .status() .unwrap(); - if !status.success() { - panic!("You should commit the protobuf files"); - } + assert!(status.success(), "You should commit the protobuf files"); } diff --git a/tonic-types/tests/bootstrap.rs b/tonic-types/tests/bootstrap.rs index d586513..01c5dfd 100644 --- a/tonic-types/tests/bootstrap.rs +++ b/tonic-types/tests/bootstrap.rs @@ -10,7 +10,7 @@ fn bootstrap() { .join("generated"); tonic_build::configure() - .out_dir(format!("{}", out_dir.display())) + .out_dir(&out_dir) .file_descriptor_set_path(out_dir.join("types.bin")) .compile(iface_files, dirs) .unwrap(); @@ -19,11 +19,9 @@ fn bootstrap() { .arg("diff") .arg("--exit-code") .arg("--") - .arg(format!("{}", out_dir.display())) + .arg(&out_dir) .status() .unwrap(); - if !status.success() { - panic!("You should commit the protobuf files"); - } + assert!(status.success(), "You should commit the protobuf files"); }