[codex] Use expect in integration tests (#28441)

The workspace denies `clippy::expect_used` in production. Although
`clippy.toml` allows `expect` in tests, Bazel Clippy compiles
integration-test helper code in a way that does not receive that
exemption, which encouraged verbose `unwrap_or_else(... panic!(...))`
and equivalent `match`/`let else` forms.

This allows `clippy::expect_used` once at each integration-test crate
root (including aggregated suites and test-support libraries), then
replaces manual panic-based Result and Option unwraps with
`expect`/`expect_err`. Standalone `tests/*.rs` files remain their own
crate roots. Intentional assertion and unexpected-variant panics remain
unchanged, and the production `expect_used = "deny"` lint remains in
place.

The cleanup is mechanical and net-negative in line count.
This commit is contained in:
pakrym-oai authored and GitHub committed 2026-06-15 21:53:47 -07:00
1 parent 08901fc8e1
commit e752f7b4ae
118 files changed
+608 -916

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
#![allow(clippy::expect_used)]
// Single integration test binary that aggregates all test modules.
// The submodules live in `tests/suite/`.
mod suite;
+2 -8
View File
@@ -1295,14 +1295,8 @@ fn jwt_with_payload(payload: serde_json::Value) -> String {
base64::engine::general_purpose::URL_SAFE_NO_PAD.encode(data)
}
let header_bytes = match serde_json::to_vec(&header) {
Ok(bytes) => bytes,
Err(err) => panic!("serialize header: {err}"),
};
let payload_bytes = match serde_json::to_vec(&payload) {
Ok(bytes) => bytes,
Err(err) => panic!("serialize payload: {err}"),
};
let header_bytes = serde_json::to_vec(&header).expect("header should serialize");
let payload_bytes = serde_json::to_vec(&payload).expect("payload should serialize");
let header_b64 = b64(&header_bytes);
let payload_b64 = b64(&payload_bytes);
let signature_b64 = b64(b"sig");
@@ -75,7 +75,7 @@ fn start_mock_issuer(chatgpt_account_id: &str) -> (SocketAddr, thread::JoinHandl
let mut resp = tiny_http::Response::from_data(data);
resp.add_header(
tiny_http::Header::from_bytes(&b"Content-Type"[..], &b"application/json"[..])
.unwrap_or_else(|_| panic!("header bytes")),
.expect("header bytes should be valid"),
);
let _ = req.respond(resp);
} else {