Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package billing
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestTokenPackMath(t *testing.T) {
|
||||
// Mirrors DebitAmount pack math: ceil(tokens/1000).
|
||||
cases := []struct {
|
||||
tokens int
|
||||
packs int
|
||||
}{
|
||||
{0, 0},
|
||||
{1, 1},
|
||||
{1000, 1},
|
||||
{1001, 2},
|
||||
{2500, 3},
|
||||
}
|
||||
for _, c := range cases {
|
||||
packs := 0
|
||||
if c.tokens > 0 {
|
||||
packs = (c.tokens + 999) / 1000
|
||||
}
|
||||
got := DebitAmount(1, 1, c.tokens)
|
||||
want := 1 + packs
|
||||
if got != want {
|
||||
t.Fatalf("tokens=%d DebitAmount=%d want %d (packs=%d)", c.tokens, got, want, packs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEstimateDebitMath(t *testing.T) {
|
||||
// Pure pack math aligned with EstimateDebit / ConsumeCredits (costs=1).
|
||||
cases := []struct {
|
||||
featureTokens int
|
||||
want int
|
||||
}{
|
||||
{0, 1}, // base feature cost only
|
||||
{1, 2},
|
||||
{1000, 2},
|
||||
{1001, 3},
|
||||
}
|
||||
for _, c := range cases {
|
||||
got := DebitAmount(1, 1, c.featureTokens)
|
||||
if got != c.want {
|
||||
t.Fatalf("tokens=%d debit=%d want %d", c.featureTokens, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user