diff options
| author | historia <[not public]> | 2026-09-18 05:31:09 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-18 05:31:09 -0400 |
| commit | 153acb7f644d755c45533b7c5311e3ffa47e8973 (patch) | |
| tree | 7645e6f7b65bc3830b078e3b9336d2e6b199d584 /internal/game/hardening_craft_combat_helpers_test.go | |
| parent | 87d08f0151e643951769e323995f1c5ed89ee200 (diff) | |
| download | thehouseoficarus-153acb7f644d755c45533b7c5311e3ffa47e8973.tar.gz | |
fix: harden engine across casino, economy, concurrency, security, and content
Diffstat (limited to 'internal/game/hardening_craft_combat_helpers_test.go')
| -rw-r--r-- | internal/game/hardening_craft_combat_helpers_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/game/hardening_craft_combat_helpers_test.go b/internal/game/hardening_craft_combat_helpers_test.go new file mode 100644 index 0000000..cfd860f --- /dev/null +++ b/internal/game/hardening_craft_combat_helpers_test.go @@ -0,0 +1,40 @@ +package game + +// Shared helpers for the crafting/combat hardening regressions. The tests +// build a real Game (owner loop, stores, craft index) over a temp data dir +// but deliberately do NOT start a background ticker, so each test drives +// production/combat cycles with explicit calls and asserts without racing +// Game.AdvanceActions. + +import ( + "os" + "path/filepath" + "testing" + + "thehouseoficarus/internal/config" + "thehouseoficarus/internal/net" +) + +// newHardeningGame builds a real Game over dir with an owner loop but no +// background ticker. stopOwner is registered for cleanup so the owner +// goroutine does not leak. +func newHardeningGame(t *testing.T, dir string) *Game { + t.Helper() + colors := &config.ColorsConfig{} + g := New(dir, colors, colors, config.ValidationConfig{}, 1) + g.SetHub(net.NewHub()) + t.Cleanup(g.stopOwner) + return g +} + +// writeDataFile writes subdir/name under dir, creating parent directories. +func writeDataFile(t *testing.T, dir, subdir, name, content string) { + t.Helper() + path := filepath.Join(dir, subdir, name) + if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { + t.Fatalf("mkdir %s: %v", subdir, err) + } + if err := os.WriteFile(path, []byte(content), 0644); err != nil { + t.Fatalf("write %s: %v", path, err) + } +} |
