Golden tests
A tariff author's statement of the bill lines a case must produce — checked on every change, failing on the first cent.
A price book carries its own tests. A golden test names a plan, a contract start (and optionally end), a period, the usage, and the lines the bill must show — optionally the totals.
[test.second-month]
plan = "glasfaser-1000"
start = "2026-10-01"
period = "2026-11"
usage = [{ id = "c1", kind = "calls-mobile", date = "2026-11-12", quantity = 754 }]
lines = [
["Glasfaser 1000", "49.99"],
["Telefon-Flat Festnetz", "4.99"],
["Router", "4.99"],
["Aktionsrabatt (Monat 2 von 3)", "-30.00"],
["Anrufe in Mobilfunknetze (13 Min.)", "2.47"],
]
totals = { gross = "32.44", vat = "5.18", net = "27.26" }telco price check runs every test and fails on the first difference:
✗ second-month
line 5: expected „Anrufe in Mobilfunknetze (13 Min.)“ 2,48 €, got „Anrufe in Mobilfunknetze (13 Min.)“ 2,47 €Tests do not change the book hash: adding a test never changes what a charge cites.
Write a test for every promise the product team made: the first month of a mid-month start, the month a promotion ends, a contract that ends on the 15th, the flat and what is outside it.
From code, run_golden(&book) returns one result per test:
# let book = telco_core::compile(&[("book.toml".to_owned(), br#"
# [book]
# id = "g"
# version = "1"
# prices = "gross"
# currency = "EUR"
# [tax.standard]
# rates = [{ from = "2021-01-01", percent = "19" }]
# [plan.p]
# name = "P"
# tax = "standard"
# recurring.base = { label = "Basis", amount = "10.00" }
# [test.full]
# plan = "p"
# start = "2026-01-01"
# period = "2026-11"
# lines = [["Basis", "10.00"]]
# "#.to_vec())])?;
for result in telco_core::run_golden(&book) {
assert!(result.passed, "{}: {:?}", result.name, result.diffs);
}
# Ok::<(), telco_core::Refusal>(())Keep a playground scenario
In the tariff playground, choose Mobile → Over allowance, then open Tariff source & tests. The preview charges €12.99 for the 26.5 GB example. Compare the expected lines and totals with the written tariff before adopting them.
Choose Download TOML. Save mobile-over-allowance.toml under pricebooks/example-mobile/tests/ and run:
telco price check pricebooks/example-mobileThe CLI lists the case by name. Change its expected gross to "13.00" and run again to see the one-cent difference. Restore the reviewed amount before committing.
The file includes contract dates, usage IDs, quantities, ordered lines and totals. Use synthetic records. The comment identifies the compiled tariff hash. If you changed a tariff file in the browser, make the same edit in the local book. The playground checks the new case before download and shows any failing tests already in the book.
Turn a sealed invoice into a regression test
In the Desk, open an invoice and download Tarifprüffall (JSON). The same case is available by invoice number or UUID with an operator credential. For the local demo:
telco --edge http://localhost:9400 export RE-2026-000002 > invoice.replay.json
telco price test invoice.replay.json --book pricebooks/example-fibreFor an example that runs entirely offline from a checkout:
telco price test samples/replay/fibre.json --book pricebooks/example-fibreThe example includes a 61-second call, its rounding and the previous month’s charges. billd captures these inputs when it seals the invoice. Later plan changes leave the case intact. For a fixed-line invoice, the complete replay expires when its first underlying call record is purged. The export then returns 410; the original invoice and its line-level explanation remain available. The verifier checks each compiled tariff hash before comparing charges, explanations, invoice lines, VAT and totals. Supply one --book DIR for each referenced version. A mismatch exits with a failure and names the first differing JSON field, such as /totals/gross, together with its expected and calculated values.
Rating cases contain operational identifiers and usage history. Keep production cases with other operator records. Customer addresses, payment details and document files are excluded. An invoice and a final bill have a case. For a credit note, download the case from the original invoice it cites.