feat: runtime manager

This commit is contained in:
Ilia Denisov
2026-04-28 20:39:18 +02:00
committed by GitHub
parent e0a99b346b
commit a7cee15115
289 changed files with 45660 additions and 2207 deletions
@@ -7,7 +7,7 @@ import (
"testing"
"time"
"galaxy/lobby/internal/adapters/gamestub"
"galaxy/lobby/internal/adapters/gameinmem"
"galaxy/lobby/internal/domain/common"
"galaxy/lobby/internal/domain/game"
"galaxy/lobby/internal/ports"
@@ -29,7 +29,7 @@ func fixedClock(at time.Time) func() time.Time {
// returns the persisted record.
func seedDraftGame(
t *testing.T,
store *gamestub.Store,
store *gameinmem.Store,
id common.GameID,
gameType game.GameType,
ownerUserID string,
@@ -73,7 +73,7 @@ func TestHandleAdminFullEditInDraft(t *testing.T) {
t.Parallel()
now := time.Date(2026, 4, 24, 10, 0, 0, 0, time.UTC)
store := gamestub.NewStore()
store := gameinmem.NewStore()
seedDraftGame(t, store, "game-a", game.GameTypePublic, "", now)
later := now.Add(30 * time.Minute)
@@ -107,7 +107,7 @@ func TestHandleOwnerEditInDraft(t *testing.T) {
t.Parallel()
now := time.Date(2026, 4, 24, 10, 0, 0, 0, time.UTC)
store := gamestub.NewStore()
store := gameinmem.NewStore()
seedDraftGame(t, store, "game-private", game.GameTypePrivate, "user-1", now)
service := newService(t, store, fixedClock(now.Add(time.Hour)))
@@ -125,7 +125,7 @@ func TestHandleNonOwnerForbidden(t *testing.T) {
t.Parallel()
now := time.Date(2026, 4, 24, 10, 0, 0, 0, time.UTC)
store := gamestub.NewStore()
store := gameinmem.NewStore()
seedDraftGame(t, store, "game-private", game.GameTypePrivate, "user-1", now)
service := newService(t, store, fixedClock(now.Add(time.Hour)))
@@ -142,7 +142,7 @@ func TestHandleUserCannotEditPublicGame(t *testing.T) {
t.Parallel()
now := time.Date(2026, 4, 24, 10, 0, 0, 0, time.UTC)
store := gamestub.NewStore()
store := gameinmem.NewStore()
seedDraftGame(t, store, "game-public", game.GameTypePublic, "", now)
service := newService(t, store, fixedClock(now.Add(time.Hour)))
@@ -159,7 +159,7 @@ func TestHandleEnrollmentOpenDescriptionOnly(t *testing.T) {
t.Parallel()
now := time.Date(2026, 4, 24, 10, 0, 0, 0, time.UTC)
store := gamestub.NewStore()
store := gameinmem.NewStore()
record := seedDraftGame(t, store, "game-open", game.GameTypePublic, "", now)
// Force status to enrollment_open via UpdateStatus.
@@ -187,7 +187,7 @@ func TestHandleEnrollmentOpenNonDescriptionRejected(t *testing.T) {
t.Parallel()
now := time.Date(2026, 4, 24, 10, 0, 0, 0, time.UTC)
store := gamestub.NewStore()
store := gameinmem.NewStore()
record := seedDraftGame(t, store, "game-open", game.GameTypePublic, "", now)
require.NoError(t, store.UpdateStatus(context.Background(), ports.UpdateStatusInput{
@@ -212,7 +212,7 @@ func TestHandleTerminalStatusRejected(t *testing.T) {
t.Parallel()
now := time.Date(2026, 4, 24, 10, 0, 0, 0, time.UTC)
store := gamestub.NewStore()
store := gameinmem.NewStore()
record := seedDraftGame(t, store, "game-cancel", game.GameTypePublic, "", now)
require.NoError(t, store.UpdateStatus(context.Background(), ports.UpdateStatusInput{
@@ -236,7 +236,7 @@ func TestHandleTerminalStatusRejected(t *testing.T) {
func TestHandleNotFound(t *testing.T) {
t.Parallel()
store := gamestub.NewStore()
store := gameinmem.NewStore()
service := newService(t, store, fixedClock(time.Date(2026, 4, 24, 10, 0, 0, 0, time.UTC)))
_, err := service.Handle(context.Background(), updategame.Input{
@@ -251,7 +251,7 @@ func TestHandleValidationFailurePropagates(t *testing.T) {
t.Parallel()
now := time.Date(2026, 4, 24, 10, 0, 0, 0, time.UTC)
store := gamestub.NewStore()
store := gameinmem.NewStore()
seedDraftGame(t, store, "game-a", game.GameTypePublic, "", now)
service := newService(t, store, fixedClock(now.Add(time.Hour)))
@@ -270,7 +270,7 @@ func TestHandleInvalidActorReturnsError(t *testing.T) {
t.Parallel()
now := time.Date(2026, 4, 24, 10, 0, 0, 0, time.UTC)
store := gamestub.NewStore()
store := gameinmem.NewStore()
service := newService(t, store, fixedClock(now))
_, err := service.Handle(context.Background(), updategame.Input{
@@ -286,7 +286,7 @@ func TestHandleInvalidGameID(t *testing.T) {
t.Parallel()
now := time.Date(2026, 4, 24, 10, 0, 0, 0, time.UTC)
store := gamestub.NewStore()
store := gameinmem.NewStore()
service := newService(t, store, fixedClock(now))
_, err := service.Handle(context.Background(), updategame.Input{