Skip to content

Commit ac64f2f

Browse files
unhappychoiceclaude
andcommitted
test(fetcher/codex_usage): compute fixture path from today's date
The `fetch_reads_jsonl_from_codex_home_env_override` test hardcoded the session directory and filename to `2026-05-23`. Once `list_session_files` started filtering by filename date (bfc728f), any fixture whose filename predates the `since="today"` cutoff (today - 1 day) is skipped before its JSONL is opened, leaving the body as "Today: no sessions". The test passed on 2026-05-23/24 and started failing on 2026-05-25. Compute the directory components and filename from `Utc::now()` so the fixture always lands inside the cutoff window. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent d65bbae commit ac64f2f

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎src/fetcher/codex/usage.rs‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ mod tests {
654654
use std::io::Write;
655655
use std::time::Duration as StdDuration;
656656

657+
use chrono::Datelike;
657658
use tempfile::tempdir;
658659

659660
use super::*;
@@ -838,14 +839,18 @@ mod tests {
838839
.lock()
839840
.unwrap_or_else(|e| e.into_inner());
840841
let tmp = tempdir().unwrap();
842+
// Path components and filename must reflect today: the file-list filter in
843+
// `list_session_files` drops anything whose filename date precedes the `since`
844+
// cutoff, so a hardcoded date bitrots after that day passes.
845+
let today = Utc::now().date_naive();
841846
let day = tmp
842847
.path()
843848
.join("sessions")
844-
.join("2026")
845-
.join("05")
846-
.join("23");
849+
.join(format!("{:04}", today.year()))
850+
.join(format!("{:02}", today.month()))
851+
.join(format!("{:02}", today.day()));
847852
fs::create_dir_all(&day).unwrap();
848-
let path = day.join("rollout-2026-05-23T00-00-00-x.jsonl");
853+
let path = day.join(format!("rollout-{today}T00-00-00-x.jsonl"));
849854
let now = Utc::now().to_rfc3339();
850855
let mut file = fs::File::create(&path).unwrap();
851856
writeln!(

0 commit comments

Comments
 (0)