fix: enable clippy on tests (#870)

https://github.com/openai/codex/pull/855 added the clippy warning to
disallow `unwrap()`, but apparently we were not verifying that tests
were "clippy clean" in CI, so I ended up with a lot of local errors in
VS Code.

This turns on the check in CI and fixes the offenders.
This commit is contained in:
Michael Bolin
2025-05-08 16:02:56 -07:00
committed by GitHub
parent 699ec5a87f
commit a9adb4175c
13 changed files with 31 additions and 11 deletions

View File

@@ -19,6 +19,7 @@ use std::time::Duration;
use codex_core::Codex;
use codex_core::config::Config;
use codex_core::error::CodexErr;
use codex_core::protocol::EventMsg;
use codex_core::protocol::InputItem;
use codex_core::protocol::Op;
@@ -32,7 +33,7 @@ fn api_key_available() -> bool {
/// Helper that spawns a fresh Agent and sends the mandatory *ConfigureSession*
/// submission. The caller receives the constructed [`Agent`] plus the unique
/// submission id used for the initialization message.
async fn spawn_codex() -> Codex {
async fn spawn_codex() -> Result<Codex, CodexErr> {
assert!(
api_key_available(),
"OPENAI_API_KEY must be set for live tests"
@@ -53,11 +54,9 @@ async fn spawn_codex() -> Codex {
}
let config = Config::load_default_config_for_test();
let (agent, _init_id) = Codex::spawn(config, std::sync::Arc::new(Notify::new()))
.await
.unwrap();
let (agent, _init_id) = Codex::spawn(config, std::sync::Arc::new(Notify::new())).await?;
agent
Ok(agent)
}
/// Verifies that the agent streams incremental *AgentMessage* events **before**
@@ -66,12 +65,13 @@ async fn spawn_codex() -> Codex {
#[ignore]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn live_streaming_and_prev_id_reset() {
#![allow(clippy::unwrap_used)]
if !api_key_available() {
eprintln!("skipping live_streaming_and_prev_id_reset OPENAI_API_KEY not set");
return;
}
let codex = spawn_codex().await;
let codex = spawn_codex().await.unwrap();
// ---------- Task 1 ----------
codex
@@ -140,12 +140,13 @@ async fn live_streaming_and_prev_id_reset() {
#[ignore]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn live_shell_function_call() {
#![allow(clippy::unwrap_used)]
if !api_key_available() {
eprintln!("skipping live_shell_function_call OPENAI_API_KEY not set");
return;
}
let codex = spawn_codex().await;
let codex = spawn_codex().await.unwrap();
const MARKER: &str = "codex_live_echo_ok";