aboutsummaryrefslogtreecommitdiff
path: root/internal/player/hardening_removeitem_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-10-05 17:05:14 -0400
committerhistoria <[not public]>2026-10-05 17:05:14 -0400
commite42952469dadfb3535633c66c881050ac128703c (patch)
treea78f7396b72cdbd6fa4f6c454c830f40cf2ad0cb /internal/player/hardening_removeitem_test.go
parent90ad8c0c33b519d5830c69d4128bdc984b5e9de8 (diff)
downloadthehouseoficarus-e42952469dadfb3535633c66c881050ac128703c.tar.gz
fix: gather verbs, walk oom, admin path bypass, roulette refund
Diffstat (limited to 'internal/player/hardening_removeitem_test.go')
-rw-r--r--internal/player/hardening_removeitem_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/player/hardening_removeitem_test.go b/internal/player/hardening_removeitem_test.go
index 5cb1e4c..b891d4e 100644
--- a/internal/player/hardening_removeitem_test.go
+++ b/internal/player/hardening_removeitem_test.go
@@ -21,3 +21,17 @@ func TestRemoveItemRejectsNonPositive(t *testing.T) {
t.Fatalf("stack mutated by a zero removal: %+v", slot)
}
}
+
+// Regression: RemoveItem used to drain every stack and only then return false,
+// so a caller that rolled back on failure lost the items anyway.
+func TestRemoveItemIsAllOrNothing(t *testing.T) {
+ p := New("alice")
+ p.SetInvSlot(0, &InventorySlot{ItemID: "coin", Quantity: 2})
+ p.SetInvSlot(1, &InventorySlot{ItemID: "coin", Quantity: 3})
+ if p.RemoveItem("coin", 10) {
+ t.Fatal("removal of more than held reported success")
+ }
+ if got := p.CountItem("coin"); got != 5 {
+ t.Fatalf("failed removal drained stacks: count = %d, want 5", got)
+ }
+}