R6(c): centralize shared integration-test fixtures in helpers.go
Move the cross-file integration fixtures — the service constructors (newGameService/newSocialService/newRobotService/newMatchmaker), the game-assembly helpers (newMirror/newGameWithSeats/newDraftGame), account provisioning (provisionAccount/provisionGuest) and the stats reader — out of the domain test files (newGameService alone was used by 10 files) into a single backend/internal/inttest/helpers.go. Helpers used by a single file stay local. Pure relocation: the helper bodies are unchanged, no test logic changes; the imports the moves left unused are pruned. go vet -tags=integration is clean.
This commit is contained in:
@@ -5,35 +5,10 @@ package inttest
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"scrabble/backend/internal/engine"
|
||||
"scrabble/backend/internal/game"
|
||||
)
|
||||
|
||||
// newDraftGame creates a started two-player English game on an opening seed and returns the
|
||||
// service, game id, seats, and the opening play (from a mirror) used to drive a real commit.
|
||||
func newDraftGame(t *testing.T) (*game.Service, uuid.UUID, []uuid.UUID, engine.MoveRecord) {
|
||||
t.Helper()
|
||||
ctx := context.Background()
|
||||
svc := newGameService()
|
||||
seats := []uuid.UUID{provisionAccount(t), provisionAccount(t)}
|
||||
seed := openingSeed(t)
|
||||
g, err := svc.Create(ctx, game.CreateParams{
|
||||
Variant: engine.VariantEnglish, Seats: seats, TurnTimeout: 24 * time.Hour, Seed: seed,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("create: %v", err)
|
||||
}
|
||||
hint, ok := newMirror(t, seed, 2).HintView()
|
||||
if !ok || len(hint.Tiles) == 0 {
|
||||
t.Fatal("no opening move")
|
||||
}
|
||||
return svc, g.ID, seats, hint
|
||||
}
|
||||
|
||||
// TestDraftPersistAndConflictReset covers draft persistence: a round-trip of the
|
||||
// rack order + board tiles, the actor's own draft cleared on their move, and an opponent's
|
||||
// board draft reset when a committed play overlaps one of its cells (the rack order kept).
|
||||
|
||||
Reference in New Issue
Block a user