Skip to content

Commit 576b8e9

Browse files
committed
CI: address review of get test split
- The 404 view test again checks the fixed reason text: it is the only thing that tells the Ok(None) arm from a fetch Err, since both record download_failed. - get_edge_cases_e2e and get_modes_e2e use the suite's shared received_paths / requests_containing instead of private copies. received_paths now panics when wiremock recording is off, so a "no request" check can't pass on an empty list. - Doc comment rewrapped. Assisted-by: Claude Code:claude-opus-5-5
1 parent d88be7a commit 576b8e9

4 files changed

Lines changed: 16 additions & 28 deletions

File tree

‎crates/socket-patch-cli/tests/get/get_edge_cases_e2e.rs‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,12 @@ use wiremock::{Mock, MockServer, ResponseTemplate};
1313
// these tests pin, and `SOCKET_MANIFEST_PATH` makes a *passing* test write
1414
// its manifest and blobs into whatever real project the variable points at.
1515
use crate::common;
16+
use crate::get_fixture::received_paths;
1617

1718
const ORG_SLUG: &str = "test-org";
1819
const UUID_A: &str = "11111111-1111-4111-8111-111111111111";
1920
const UUID_B: &str = "22222222-2222-4222-8222-222222222222";
2021

21-
/// Collect the paths of every request the mock actually received. Used to
22-
/// prove which code path the binary really took (vs. fabricating the right
23-
/// envelope without touching the network it claims to touch).
24-
async fn received_paths(mock: &MockServer) -> Vec<String> {
25-
mock.received_requests()
26-
.await
27-
.expect("wiremock must record received requests")
28-
.iter()
29-
.map(|r| r.url.path().to_string())
30-
.collect()
31-
}
32-
3322
/// A single-file patch-view `files` map that survives the "patch has no
3423
/// applicable files" guardrail (a fetched view whose `files_for_manifest`
3524
/// map is empty is an exit-1 failure, not a silent `applied:1`). The tests

‎crates/socket-patch-cli/tests/get/get_failure_paths.rs‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,12 @@ async fn engine_view_404_is_download_failed() {
406406
json["events"][0]["errorCode"], "download_failed",
407407
"json={json}"
408408
);
409+
// A fetch `Err` records `download_failed` too, with the error's own
410+
// text: this fixed reason is the only mark of the `Ok(None)` arm.
411+
assert_eq!(
412+
json["events"][0]["error"], "could not fetch details",
413+
"json={json}"
414+
);
409415
assert_no_manifest(tmp.path());
410416
}
411417

@@ -1202,9 +1208,9 @@ async fn vendored_lock_held_vendor_step_errors_without_vendor_envelope() {
12021208
/// `get <uuid> --mode hosted` folds its result into the HOSTED error
12031209
/// envelope, so a held apply lock surfaces as the top-level
12041210
/// `error: {code: "lock_held", message}` object (v5.0: no top-level
1205-
/// `errorCode`) — exit 1, nothing written. The human arm's lock error line
1206-
/// and wait hint are pinned in `get_render.rs`. A `--dry-run` never contends: it previews the redirect under the held
1207-
/// lock and exits 0.
1211+
/// `errorCode`) — exit 1, nothing written. A `--dry-run` never contends:
1212+
/// it previews the redirect under the held lock and exits 0. The human
1213+
/// arm's lock error line and wait hint are pinned in `get_render.rs`.
12081214
#[tokio::test]
12091215
async fn hosted_lock_held_get_errors_with_top_level_error_code() {
12101216
let (server, tmp, _lock) = hosted_project_with_held_lock().await;

‎crates/socket-patch-cli/tests/get/get_fixture.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,14 @@ pub fn prestage_lock_file(socket: &Path) {
220220
std::fs::write(socket.join("apply.lock"), b"").unwrap();
221221
}
222222

223+
/// The path of every request the mock received: which code path the binary
224+
/// really took. Panics when recording is off, so an empty list never passes
225+
/// a "no request" check vacuously.
223226
pub async fn received_paths(server: &MockServer) -> Vec<String> {
224227
server
225228
.received_requests()
226229
.await
227-
.unwrap_or_default()
230+
.expect("wiremock must record received requests")
228231
.iter()
229232
.map(|r| r.url.path().to_string())
230233
.collect()
@@ -680,7 +683,7 @@ pub fn traversal_files() -> serde_json::Value {
680683

681684
/// Subprocess `get` with no `--api-token` / `--org`: the scrubbed child
682685
/// falls back to the public proxy, seeded at `uri` through
683-
/// `SOCKET_PROXY_URL` (get_invariants' recipe).
686+
/// `SOCKET_PROXY_URL`.
684687
pub fn run_get_via_proxy(cwd: &Path, uri: &str, extra: &[&str]) -> (i32, String, String) {
685688
let mut args = vec!["get"];
686689
args.extend_from_slice(extra);

‎crates/socket-patch-cli/tests/get/get_modes_e2e.rs‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use wiremock::matchers::{method, path};
2525
use wiremock::{Mock, MockServer, ResponseTemplate};
2626

2727
use crate::common;
28+
use crate::get_fixture::requests_containing;
2829
use crate::npm_e2e_common;
2930
use crate::vex_e2e_common;
3031

@@ -206,17 +207,6 @@ fn parse_single_json_doc(stdout: &str) -> serde_json::Value {
206207
})
207208
}
208209

209-
/// Requests the mock server saw for a given path fragment.
210-
async fn requests_containing(server: &MockServer, fragment: &str) -> usize {
211-
server
212-
.received_requests()
213-
.await
214-
.unwrap_or_default()
215-
.iter()
216-
.filter(|r| r.url.path().contains(fragment))
217-
.count()
218-
}
219-
220210
// ---------------------------------------------------------------------------
221211
// (1) hosted envelope
222212
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)