Skip to content

Commit c4e9288

Browse files
committed
fix: suppress deprecated cargo_bin warnings in tests
Centralized Command::cargo_bin usage in a helper function with #[allow(deprecated)] to avoid clippy warnings while maintaining test functionality.
1 parent e94c44a commit c4e9288

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

‎tests/integration_test.rs‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
use assert_cmd::Command;
22
use uuid::Uuid;
33

4+
#[allow(deprecated)]
5+
fn get_cmd() -> Command {
6+
Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap()
7+
}
8+
49
#[test]
510
fn test_default_generates_v7() {
6-
let mut cmd = Command::cargo_bin("mkid").unwrap();
11+
let mut cmd = get_cmd();
712
let output = cmd.assert().success();
813
let stdout = String::from_utf8(output.get_output().stdout.clone()).unwrap();
914
let uuid_str = stdout.trim();
@@ -17,7 +22,7 @@ fn test_default_generates_v7() {
1722

1823
#[test]
1924
fn test_uuid_v4() {
20-
let mut cmd = Command::cargo_bin("mkid").unwrap();
25+
let mut cmd = get_cmd();
2126
let output = cmd.args(["uuid", "v4"]).assert().success();
2227
let stdout = String::from_utf8(output.get_output().stdout.clone()).unwrap();
2328
let uuid_str = stdout.trim();
@@ -28,14 +33,14 @@ fn test_uuid_v4() {
2833

2934
#[test]
3035
fn test_uuid_v5_deterministic() {
31-
let mut cmd1 = Command::cargo_bin("mkid").unwrap();
36+
let mut cmd1 = get_cmd();
3237
let output1 = cmd1
3338
.args(["uuid", "v5", "--namespace", "dns", "--name", "example.com"])
3439
.assert()
3540
.success();
3641
let uuid1 = String::from_utf8(output1.get_output().stdout.clone()).unwrap();
3742

38-
let mut cmd2 = Command::cargo_bin("mkid").unwrap();
43+
let mut cmd2 = get_cmd();
3944
let output2 = cmd2
4045
.args(["uuid", "v5", "--namespace", "dns", "--name", "example.com"])
4146
.assert()
@@ -47,7 +52,7 @@ fn test_uuid_v5_deterministic() {
4752

4853
#[test]
4954
fn test_format_simple() {
50-
let mut cmd = Command::cargo_bin("mkid").unwrap();
55+
let mut cmd = get_cmd();
5156
let output = cmd
5257
.args(["uuid", "v7", "--format", "simple"])
5358
.assert()
@@ -62,7 +67,7 @@ fn test_format_simple() {
6267

6368
#[test]
6469
fn test_format_urn() {
65-
let mut cmd = Command::cargo_bin("mkid").unwrap();
70+
let mut cmd = get_cmd();
6671
let output = cmd
6772
.args(["uuid", "v7", "--format", "urn"])
6873
.assert()
@@ -75,7 +80,7 @@ fn test_format_urn() {
7580

7681
#[test]
7782
fn test_format_braced() {
78-
let mut cmd = Command::cargo_bin("mkid").unwrap();
83+
let mut cmd = get_cmd();
7984
let output = cmd
8085
.args(["uuid", "v7", "--format", "braced"])
8186
.assert()
@@ -89,7 +94,7 @@ fn test_format_braced() {
8994

9095
#[test]
9196
fn test_uppercase() {
92-
let mut cmd = Command::cargo_bin("mkid").unwrap();
97+
let mut cmd = get_cmd();
9398
let output = cmd.args(["uuid", "v7", "--uppercase"]).assert().success();
9499
let stdout = String::from_utf8(output.get_output().stdout.clone()).unwrap();
95100
let uuid_str = stdout.trim();
@@ -107,7 +112,7 @@ fn test_uppercase() {
107112

108113
#[test]
109114
fn test_count() {
110-
let mut cmd = Command::cargo_bin("mkid").unwrap();
115+
let mut cmd = get_cmd();
111116
let output = cmd.args(["uuid", "v7", "--count", "5"]).assert().success();
112117
let stdout = String::from_utf8(output.get_output().stdout.clone()).unwrap();
113118
let lines: Vec<&str> = stdout.lines().collect();
@@ -122,7 +127,7 @@ fn test_count() {
122127

123128
#[test]
124129
fn test_v7_monotonic() {
125-
let mut cmd = Command::cargo_bin("mkid").unwrap();
130+
let mut cmd = get_cmd();
126131
let output = cmd.args(["uuid", "v7", "--count", "10"]).assert().success();
127132
let stdout = String::from_utf8(output.get_output().stdout.clone()).unwrap();
128133
let lines: Vec<&str> = stdout.lines().collect();
@@ -140,7 +145,7 @@ fn test_v7_monotonic() {
140145

141146
#[test]
142147
fn test_error_v5_missing_name() {
143-
let mut cmd = Command::cargo_bin("mkid").unwrap();
148+
let mut cmd = get_cmd();
144149
cmd.args(["uuid", "v5", "--namespace", "dns"])
145150
.assert()
146151
.failure()
@@ -149,7 +154,7 @@ fn test_error_v5_missing_name() {
149154

150155
#[test]
151156
fn test_error_v8_invalid_bytes() {
152-
let mut cmd = Command::cargo_bin("mkid").unwrap();
157+
let mut cmd = get_cmd();
153158
cmd.args(["uuid", "v8", "--bytes", "123"])
154159
.assert()
155160
.failure()

0 commit comments

Comments
 (0)