oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package team
2
3import "testing"
4
5func TestAuditedSettlementPreservesLateHigherUsage(t *testing.T) {
6 e := newEnv(t)
7 _, scope := e.createJob(softwareSpec(SoftwareSteps(false)))
8 h := e.claim(scope, "reproduce", "runner", "workspace")
9 id, err := e.store.Intend(e.ctx, scope, h, intent("late", Usage{InputTokens: 10, OutputTokens: 20}))
10 must(t, err)
11 _, err = e.store.Admit(e.ctx, scope, id)
12 must(t, err)
13 must(t, e.store.Lost(e.ctx, scope, id, "unknown"))
14 usage := &Usage{Calls: 3, InputTokens: 50, OutputTokens: 60, CostMicros: 9000}
15 must(t, e.store.Record(e.ctx, scope, id, Receipt{ID: "late", Outcome: OutcomeSuccess, Usage: usage}))
16 rows, err := e.store.Reservations(e.ctx, scope)
17 must(t, err)
18 before := rows[0].Settled
19 if before != *usage {
20 t.Fatalf("late usage missing: %+v", rows[0])
21 }
22 after, err := e.store.SettleAudited(e.ctx, scope, rows[0].ID, "operator", "retain unknown charge")
23 must(t, err)
24 if after.Settled != before {
25 t.Fatalf("audit lowered late charge: before=%+v after=%+v", before, after.Settled)
26 }
27}
28