Skip to content

Commit 0373b5f

Browse files
committed
test(codex): cover archived session path cases
Add fixture-backed coverage for sessions-only, archived-sessions-only, and direct JSONL directory fallback path discovery. This addresses the CodeRabbit review gap while preserving the archived session discovery behavior added in the prior commit.
1 parent 28e2e29 commit 0373b5f

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

  • rust/crates/ccusage/src/adapter/codex

‎rust/crates/ccusage/src/adapter/codex/paths.rs‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,34 @@ mod tests {
6868
]
6969
);
7070
}
71+
72+
#[test]
73+
fn uses_sessions_without_missing_archived_sessions_path() {
74+
let fixture = Fixture::new();
75+
let _ = fixture.create_dir_all("codex/sessions");
76+
77+
let paths = codex_usage_paths_from_homes(vec![fixture.path("codex")]);
78+
79+
assert_eq!(paths, vec![fixture.path("codex/sessions")]);
80+
}
81+
82+
#[test]
83+
fn uses_archived_sessions_without_direct_path_fallback() {
84+
let fixture = Fixture::new();
85+
let _ = fixture.create_dir_all("codex/archived_sessions");
86+
87+
let paths = codex_usage_paths_from_homes(vec![fixture.path("codex")]);
88+
89+
assert_eq!(paths, vec![fixture.path("codex/archived_sessions")]);
90+
}
91+
92+
#[test]
93+
fn falls_back_to_direct_path_when_no_session_directories_exist() {
94+
let fixture = Fixture::new();
95+
let home = fixture.create_dir_all("codex");
96+
97+
let paths = codex_usage_paths_from_homes(vec![home.clone()]);
98+
99+
assert_eq!(paths, vec![home]);
100+
}
71101
}

0 commit comments

Comments
 (0)