oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package chat
2
3import "testing"
4
5// Each row's part of a task's spend: Claude's cache reads and writes
6// beside its input, Codex's cached input inside it; a lower bound when
7// any figure the sum needs is missing or the attempt's final usage
8// message was not seen.
9func TestRowSpend(t *testing.T) {
10 n := func(v int64) *int64 { return &v }
11 claude := usageRecord{Provider: "claude", Complete: true, InputTokens: n(2), CachedInputTokens: n(3566), CacheWriteTokens: n(378), OutputTokens: n(3)}
12 codex := usageRecord{Provider: "codex", Complete: true, InputTokens: n(9000), CachedInputTokens: n(4000), OutputTokens: n(1000)}
13 if got := rowSpend(claude); got != (Spend{Tokens: 3949, Cached: 3566}) {
14 t.Fatalf("claude %+v", got)
15 }
16 if got := rowSpend(codex); got != (Spend{Tokens: 10000, Cached: 4000}) {
17 t.Fatalf("codex %+v", got)
18 }
19 for name, r := range map[string]usageRecord{
20 "incomplete": func() usageRecord { r := codex; r.Complete = false; return r }(),
21 "no input": func() usageRecord { r := codex; r.InputTokens = nil; return r }(),
22 "no output": func() usageRecord { r := codex; r.OutputTokens = nil; return r }(),
23 "no cached": func() usageRecord { r := codex; r.CachedInputTokens = nil; return r }(),
24 "claude no cache write": func() usageRecord { r := claude; r.CacheWriteTokens = nil; return r }(),
25 } {
26 if !rowSpend(r).Partial {
27 t.Fatalf("%s: not a lower bound", name)
28 }
29 }
30 // Codex reports no cache-write figure: that alone is no gap.
31 if rowSpend(codex).Partial {
32 t.Fatal("codex without a cache-write figure is partial")
33 }
34}
35