diff options
| author | historia <[not public]> | 2026-09-15 15:35:52 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-15 15:35:52 -0400 |
| commit | 0b0b25222b3131ada79ff78c28eb8bf07d977deb (patch) | |
| tree | 2ceaef5203595044f66a8f00064cd8e017f8f48d /internal/casino/manager_test.go | |
| parent | 396c3facb8287b9a34076cae8f3d7b300d366d99 (diff) | |
| download | thehouseoficarus-0b0b25222b3131ada79ff78c28eb8bf07d977deb.tar.gz | |
feat: single-owner game state, transactional lifecycle, durable money on server stop
Diffstat (limited to 'internal/casino/manager_test.go')
| -rw-r--r-- | internal/casino/manager_test.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/internal/casino/manager_test.go b/internal/casino/manager_test.go index 134798a..50cf114 100644 --- a/internal/casino/manager_test.go +++ b/internal/casino/manager_test.go @@ -6,9 +6,9 @@ type testWallet struct { chips, credits, paid int } -func (w *testWallet) Wager(amount int) (Wager, bool) { +func (w *testWallet) Wager(amount int) (Wager, error) { if w.chips+w.credits < amount { - return Wager{}, false + return Wager{}, ErrInsufficientFunds } chips := amount if chips > w.chips { @@ -17,17 +17,18 @@ func (w *testWallet) Wager(amount int) (Wager, bool) { w.chips -= chips credits := amount - chips w.credits -= credits - return Wager{Total: amount, Chips: chips, Credits: credits}, true + return Wager{Total: amount, Chips: chips, Credits: credits}, nil } -func (w *testWallet) PayCredits(amount int) { +func (w *testWallet) PayCredits(amount int) error { w.paid += amount + return nil } func TestMixedWagerUsesChipsFirst(t *testing.T) { w := &testWallet{chips: 7, credits: 50} - wager, ok := w.Wager(12) - if !ok || wager.Chips != 7 || wager.Credits != 5 || w.chips != 0 || w.credits != 45 { + wager, err := w.Wager(12) + if err != nil || wager.Chips != 7 || wager.Credits != 5 || w.chips != 0 || w.credits != 45 { t.Fatalf("unexpected wager: %+v wallet=%+v", wager, w) } } |
