Skip to content

Commit c9946e8

Browse files
committed
test(cline): assert recorded costs render in table reports
The shared Cline fixture totals $0.0012, so every cost cell in the table snapshots renders as $0.00 and a broken table cost path would not change them. Add a fixture with $1.25 and $2.50 recorded costs and assert that the Total row of each report kind renders $3.75.
1 parent c9c729c commit c9946e8

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎rust/crates/ccusage/tests/cline_cli.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@ fn snapshots_cline_focused_json_and_table_reports_for_all_kinds() {
1818
}
1919
}
2020

21+
#[test]
22+
fn table_reports_render_recorded_costs() {
23+
let fixture = fs_fixture!({
24+
"data/sessions/costly/costly.messages.json": r#"{"version":1,"sessionId":"costly","messages":[{"role":"assistant","ts":1793491260000,"id":"costly-1","modelInfo":{"id":"claude-sonnet-4-20250514","provider":"anthropic"},"metrics":{"inputTokens":1000,"outputTokens":200,"cacheReadTokens":0,"cacheWriteTokens":0,"cost":1.25}},{"role":"assistant","ts":1793491320000,"id":"costly-2","modelInfo":{"id":"claude-sonnet-4-20250514","provider":"anthropic"},"metrics":{"inputTokens":500,"outputTokens":100,"cacheReadTokens":0,"cacheWriteTokens":0,"cost":2.5}}]}"#,
25+
});
26+
27+
for kind in ["daily", "weekly", "monthly", "session"] {
28+
let table_output = run_cli(&fixture, kind, false);
29+
let total_row = table_output
30+
.lines()
31+
.find(|line| line.starts_with("│ Total "))
32+
.unwrap_or_else(|| panic!("{kind} table should have a Total row:\n{table_output}"));
33+
assert!(
34+
total_row.contains("$3.75"),
35+
"{kind} Total row should render the recorded cost: {total_row}"
36+
);
37+
}
38+
}
39+
2140
fn assert_only_accepted_requests_are_reported(report: &serde_json::Value, kind: &str) {
2241
let totals = &report["totals"];
2342
for (key, expected) in [

0 commit comments

Comments
 (0)