Skip to content

Commit 7f4bc44

Browse files
authored
fix: remove usage of deprecated 'assert_cmd::Command' (#942)
1 parent cdb2c8e commit 7f4bc44

1 file changed

Lines changed: 56 additions & 73 deletions

File tree

cargo-typify/tests/integration.rs

Lines changed: 56 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use tempdir::TempDir;
44

55
#[test]
66
fn test_simple() {
7-
use assert_cmd::Command;
8-
97
let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json");
108

119
let temp = TempDir::new("cargo-typify").unwrap();
@@ -14,8 +12,8 @@ fn test_simple() {
1412

1513
let output_file = temp.path().join("simple.rs");
1614

17-
let mut cmd = Command::cargo_bin("cargo-typify").unwrap();
18-
cmd.args(["typify", input_file.to_str().unwrap()])
15+
assert_cmd::cargo::cargo_bin_cmd!()
16+
.args(["typify", input_file.to_str().unwrap()])
1917
.assert()
2018
.success();
2119

@@ -26,15 +24,13 @@ fn test_simple() {
2624

2725
#[test]
2826
fn test_default_output() {
29-
use assert_cmd::Command;
30-
3127
let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json");
3228

3329
let temp = TempDir::new("cargo-typify").unwrap();
3430
let output_file = temp.path().join("output.rs");
3531

36-
let mut cmd = Command::cargo_bin("cargo-typify").unwrap();
37-
cmd.args(["typify", input, "--output", output_file.to_str().unwrap()])
32+
assert_cmd::cargo::cargo_bin_cmd!()
33+
.args(["typify", input, "--output", output_file.to_str().unwrap()])
3834
.assert()
3935
.success();
4036

@@ -45,13 +41,9 @@ fn test_default_output() {
4541

4642
#[test]
4743
fn test_no_builder_stdout() {
48-
use assert_cmd::Command;
49-
5044
let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json");
5145

52-
let mut cmd = Command::cargo_bin("cargo-typify").unwrap();
53-
54-
let output = cmd
46+
let output = assert_cmd::cargo::cargo_bin_cmd!()
5547
.args(["typify", input, "--no-builder", "--output", "-"])
5648
.output()
5749
.unwrap();
@@ -65,23 +57,21 @@ fn test_no_builder_stdout() {
6557

6658
#[test]
6759
fn test_builder() {
68-
use assert_cmd::Command;
69-
7060
let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json");
7161

7262
let temp = TempDir::new("cargo-typify").unwrap();
7363
let output_file = temp.path().join("output.rs");
7464

75-
let mut cmd = Command::cargo_bin("cargo-typify").unwrap();
76-
cmd.args([
77-
"typify",
78-
input,
79-
"--builder",
80-
"--output",
81-
output_file.to_str().unwrap(),
82-
])
83-
.assert()
84-
.success();
65+
assert_cmd::cargo::cargo_bin_cmd!()
66+
.args([
67+
"typify",
68+
input,
69+
"--builder",
70+
"--output",
71+
output_file.to_str().unwrap(),
72+
])
73+
.assert()
74+
.success();
8575

8676
let actual = std::fs::read_to_string(output_file).unwrap();
8777

@@ -90,25 +80,23 @@ fn test_builder() {
9080

9181
#[test]
9282
fn test_derive() {
93-
use assert_cmd::Command;
94-
9583
let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json");
9684

9785
let temp = TempDir::new("cargo-typify").unwrap();
9886
let output_file = temp.path().join("output.rs");
9987

100-
let mut cmd = Command::cargo_bin("cargo-typify").unwrap();
101-
cmd.args([
102-
"typify",
103-
input,
104-
"--no-builder",
105-
"--additional-derive",
106-
"ExtraDerive",
107-
"--output",
108-
output_file.to_str().unwrap(),
109-
])
110-
.assert()
111-
.success();
88+
assert_cmd::cargo::cargo_bin_cmd!()
89+
.args([
90+
"typify",
91+
input,
92+
"--no-builder",
93+
"--additional-derive",
94+
"ExtraDerive",
95+
"--output",
96+
output_file.to_str().unwrap(),
97+
])
98+
.assert()
99+
.success();
112100

113101
let actual = std::fs::read_to_string(output_file).unwrap();
114102

@@ -117,27 +105,25 @@ fn test_derive() {
117105

118106
#[test]
119107
fn test_multi_derive() {
120-
use assert_cmd::Command;
121-
122108
let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json");
123109

124110
let temp = TempDir::new("cargo-typify").unwrap();
125111
let output_file = temp.path().join("output.rs");
126112

127-
let mut cmd = Command::cargo_bin("cargo-typify").unwrap();
128-
cmd.args([
129-
"typify",
130-
input,
131-
"--no-builder",
132-
"--additional-derive",
133-
"ExtraDerive",
134-
"--additional-derive",
135-
"AnotherDerive",
136-
"--output",
137-
output_file.to_str().unwrap(),
138-
])
139-
.assert()
140-
.success();
113+
assert_cmd::cargo::cargo_bin_cmd!()
114+
.args([
115+
"typify",
116+
input,
117+
"--no-builder",
118+
"--additional-derive",
119+
"ExtraDerive",
120+
"--additional-derive",
121+
"AnotherDerive",
122+
"--output",
123+
output_file.to_str().unwrap(),
124+
])
125+
.assert()
126+
.success();
141127

142128
let actual = std::fs::read_to_string(output_file).unwrap();
143129

@@ -146,11 +132,10 @@ fn test_multi_derive() {
146132

147133
#[test]
148134
fn test_help() {
149-
use assert_cmd::Command;
150-
151-
let mut cmd = Command::cargo_bin("cargo-typify").unwrap();
152-
153-
let output = cmd.args(["typify", "--help"]).output().unwrap();
135+
let output = assert_cmd::cargo::cargo_bin_cmd!()
136+
.args(["typify", "--help"])
137+
.output()
138+
.unwrap();
154139

155140
let output_stdout = String::from_utf8(output.stdout).unwrap();
156141
let actual = dos2unix(&output_stdout);
@@ -161,24 +146,22 @@ fn test_help() {
161146

162147
#[test]
163148
fn test_btree_map() {
164-
use assert_cmd::Command;
165-
166149
let input = concat!(env!("CARGO_MANIFEST_DIR"), "/../example.json");
167150

168151
let temp = TempDir::new("cargo-typify").unwrap();
169152
let output_file = temp.path().join("output.rs");
170153

171-
let mut cmd = Command::cargo_bin("cargo-typify").unwrap();
172-
cmd.args([
173-
"typify",
174-
input,
175-
"--map-type",
176-
"::std::collections::BTreeMap",
177-
"--output",
178-
output_file.to_str().unwrap(),
179-
])
180-
.assert()
181-
.success();
154+
assert_cmd::cargo::cargo_bin_cmd!()
155+
.args([
156+
"typify",
157+
input,
158+
"--map-type",
159+
"::std::collections::BTreeMap",
160+
"--output",
161+
output_file.to_str().unwrap(),
162+
])
163+
.assert()
164+
.success();
182165

183166
let actual = std::fs::read_to_string(output_file).unwrap();
184167

0 commit comments

Comments
 (0)