chore(cleanup): purge /command residuals — fakeEngine, canon golden, openapi
Tests · UI / test (pull_request) Has been cancelled
Tests · Integration / integration (pull_request) Successful in 1m46s
Tests · Go / test (pull_request) Successful in 2m4s
Tests · Go / test (push) Successful in 2m28s
Tests · UI / test (push) Successful in 3m22s

Follow-up tidy after the cross-service /command removal (#73):

- Rename the router test double dummyExecutor -> fakeEngine (and the
  newExecutor / setupRouterExecutor helpers -> newFakeEngine /
  setupRouterEngine): it implements handler.Engine now, "executor" was a
  leftover of the removed adapter. Test-only.

- Regenerate the ui/core canon signing golden onto user.games.order
  (request_user_games_command.json -> request_user_games_order.json, fresh
  canonical bytes + Ed25519 signature) and drop the last
  user.games.command references from the Go/TS tests and docs.

- Align game openapi: CommandRequest.cmd no longer carries minItems: 1. It
  is now used only by PUT /api/v1/order, which accepts an empty batch
  (clearing the player's stored order, equivalent to removing every
  command); the contract test freezes the empty-allowed shape.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilia Denisov
2026-05-30 15:16:17 +02:00
parent 40d6ba6ba4
commit bde9d535dc
11 changed files with 67 additions and 63 deletions
+23 -23
View File
@@ -68,8 +68,8 @@ func TestOrderRaceQuit(t *testing.T) {
payload = &rest.Command{
Actor: commandDefaultActor,
}
exec := &dummyExecutor{}
emptyRouter := setupRouterExecutor(exec)
exec := &fakeEngine{}
emptyRouter := setupRouterEngine(exec)
w = httptest.NewRecorder()
req, _ = http.NewRequest(apiCommandMethod, apiOrderPath, asBody(payload))
@@ -927,8 +927,8 @@ func TestOrderPlanetRouteRemove(t *testing.T) {
}
func TestMultipleCommandOrder(t *testing.T) {
e := newExecutor()
r := setupRouterExecutor(e)
e := newFakeEngine()
r := setupRouterEngine(e)
payload := &rest.Command{
Actor: commandDefaultActor,
@@ -951,11 +951,11 @@ func TestMultipleCommandOrder(t *testing.T) {
assert.Equal(t, commandNoErrorsStatus, w.Code, w.Body)
assert.Equal(t, 2, e.(*dummyExecutor).CommandsExecuted)
assert.Equal(t, 2, e.(*fakeEngine).CommandsExecuted)
}
func TestPutOrderResponseBody(t *testing.T) {
e := &dummyExecutor{
e := &fakeEngine{
ValidateOrderResult: &order.UserGamesOrder{
GameID: uuid.New(),
UpdatedAt: 1700,
@@ -967,7 +967,7 @@ func TestPutOrderResponseBody(t *testing.T) {
},
},
}
r := setupRouterExecutor(e)
r := setupRouterEngine(e)
payload := &rest.Command{
Actor: commandDefaultActor,
@@ -997,8 +997,8 @@ func TestPutOrderResponseBody(t *testing.T) {
}
func TestPutOrderEngineError(t *testing.T) {
e := &dummyExecutor{ValidateOrderErr: errors.New("engine boom")}
r := setupRouterExecutor(e)
e := &fakeEngine{ValidateOrderErr: errors.New("engine boom")}
r := setupRouterEngine(e)
payload := &rest.Command{
Actor: commandDefaultActor,
@@ -1054,8 +1054,8 @@ func TestPutOrderPerCommandRejection(t *testing.T) {
},
},
}
executor := &dummyExecutor{ValidateOrderResult: result}
r := setupRouterExecutor(executor)
executor := &fakeEngine{ValidateOrderResult: result}
r := setupRouterEngine(executor)
payload := &rest.Command{
Actor: commandDefaultActor,
@@ -1112,8 +1112,8 @@ func TestPutOrderPerCommandRejection(t *testing.T) {
// *GenericError on the input shelf, which must map to HTTP 400 with
// the `{"generic_error","code"}` envelope rather than 500.
func TestPutOrderStructuralRejection(t *testing.T) {
executor := &dummyExecutor{ValidateOrderErr: e.NewQuitCommandFollowedByCommandError()}
r := setupRouterExecutor(executor)
executor := &fakeEngine{ValidateOrderErr: e.NewQuitCommandFollowedByCommandError()}
r := setupRouterEngine(executor)
payload := &rest.Command{
Actor: commandDefaultActor,
@@ -1152,8 +1152,8 @@ func TestGetOrderQueryValidation(t *testing.T) {
{"Non-numeric turn", "?player=Race_01&turn=abc", http.StatusBadRequest},
} {
t.Run(tc.description, func(t *testing.T) {
e := &dummyExecutor{}
r := setupRouterExecutor(e)
e := &fakeEngine{}
r := setupRouterEngine(e)
w := httptest.NewRecorder()
req, _ := http.NewRequest(http.MethodGet, apiOrderPath+tc.query, nil)
@@ -1176,11 +1176,11 @@ func TestGetOrderFound(t *testing.T) {
},
},
}
e := &dummyExecutor{
e := &fakeEngine{
FetchOrderResult: stored,
FetchOrderOK: true,
}
r := setupRouterExecutor(e)
r := setupRouterEngine(e)
w := httptest.NewRecorder()
req, _ := http.NewRequest(http.MethodGet, apiOrderPath+"?player=Race_01&turn=3", nil)
@@ -1202,11 +1202,11 @@ func TestGetOrderFound(t *testing.T) {
}
func TestGetOrderTurnDefaultsToZero(t *testing.T) {
e := &dummyExecutor{
e := &fakeEngine{
FetchOrderResult: &order.UserGamesOrder{GameID: uuid.New(), UpdatedAt: 1, Commands: []order.DecodableCommand{}},
FetchOrderOK: true,
}
r := setupRouterExecutor(e)
r := setupRouterEngine(e)
w := httptest.NewRecorder()
req, _ := http.NewRequest(http.MethodGet, apiOrderPath+"?player=Race_01", nil)
@@ -1217,8 +1217,8 @@ func TestGetOrderTurnDefaultsToZero(t *testing.T) {
}
func TestGetOrderNotFound(t *testing.T) {
e := &dummyExecutor{FetchOrderOK: false}
r := setupRouterExecutor(e)
e := &fakeEngine{FetchOrderOK: false}
r := setupRouterEngine(e)
w := httptest.NewRecorder()
req, _ := http.NewRequest(http.MethodGet, apiOrderPath+"?player=Race_01&turn=2", nil)
@@ -1231,8 +1231,8 @@ func TestGetOrderNotFound(t *testing.T) {
}
func TestGetOrderEngineError(t *testing.T) {
e := &dummyExecutor{FetchOrderErr: errors.New("engine boom")}
r := setupRouterExecutor(e)
e := &fakeEngine{FetchOrderErr: errors.New("engine boom")}
r := setupRouterEngine(e)
w := httptest.NewRecorder()
req, _ := http.NewRequest(http.MethodGet, apiOrderPath+"?player=Race_01&turn=0", nil)