Skip to content

Commit 4c06c8c

Browse files
authored
update httpmock generation to support 0.8 (#1264)
1 parent 05fe1d3 commit 4c06c8c

File tree

5 files changed

+179
-1080
lines changed

5 files changed

+179
-1080
lines changed

cargo-progenitor/tests/test_cmd.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// Copyright 2025 Oxide Computer Company
22

3-
use assert_cmd::Command;
4-
53
#[test]
64
fn test_help() {
7-
Command::cargo_bin("cargo-progenitor")
8-
.unwrap()
5+
assert_cmd::cargo::cargo_bin_cmd!()
96
.arg("progenitor")
107
.arg("--help")
118
.assert()

progenitor-impl/src/httpmock.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,7 @@ impl Generator {
208208
value.to_string(),
209209
))
210210
} else {
211-
Self(self.0.matches(|req| {
212-
req.query_params
213-
.as_ref()
214-
.and_then(|qs| {
215-
qs.iter().find(
216-
|(key, _)| key == #api_name)
217-
})
218-
.is_none()
219-
}))
211+
Self(self.0.query_param_missing(#api_name))
220212
}
221213
},
222214
),
@@ -229,16 +221,7 @@ impl Generator {
229221
value.to_string()
230222
))
231223
} else {
232-
Self(self.0.matches(|req| {
233-
req.headers
234-
.as_ref()
235-
.and_then(|hs| {
236-
hs.iter().find(
237-
|(key, _)| key == #api_name
238-
)
239-
})
240-
.is_none()
241-
}))
224+
Self(self.0.header_missing(#api_name))
242225
}
243226
},
244227
),
@@ -247,7 +230,6 @@ impl Generator {
247230
true,
248231
quote! {
249232
Self(self.0.json_body_obj(value))
250-
251233
},
252234
),
253235
OperationParameterType::RawBody => match body_content_type {

progenitor-impl/tests/output/src/buildomat_httpmock.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,7 @@ pub mod operations {
210210
if let Some(value) = value.into() {
211211
Self(self.0.query_param("minseq", value.to_string()))
212212
} else {
213-
Self(self.0.matches(|req| {
214-
req.query_params
215-
.as_ref()
216-
.and_then(|qs| qs.iter().find(|(key, _)| key == "minseq"))
217-
.is_none()
218-
}))
213+
Self(self.0.query_param_missing("minseq"))
219214
}
220215
}
221216
}
@@ -763,12 +758,7 @@ pub mod operations {
763758
if let Some(value) = value.into() {
764759
Self(self.0.query_param("id", value.to_string()))
765760
} else {
766-
Self(self.0.matches(|req| {
767-
req.query_params
768-
.as_ref()
769-
.and_then(|qs| qs.iter().find(|(key, _)| key == "id"))
770-
.is_none()
771-
}))
761+
Self(self.0.query_param_missing("id"))
772762
}
773763
}
774764
}
@@ -814,12 +804,7 @@ pub mod operations {
814804
if let Some(value) = value.into() {
815805
Self(self.0.header("accept-language", value.to_string()))
816806
} else {
817-
Self(self.0.matches(|req| {
818-
req.headers
819-
.as_ref()
820-
.and_then(|hs| hs.iter().find(|(key, _)| key == "accept-language"))
821-
.is_none()
822-
}))
807+
Self(self.0.header_missing("accept-language"))
823808
}
824809
}
825810
}

0 commit comments

Comments
 (0)