test: multiple commands

This commit is contained in:
IliaDenisov
2026-02-12 12:50:09 +03:00
parent 7c4e2a6f88
commit 67f0fdef61
3 changed files with 44 additions and 6 deletions
+28
View File
@@ -921,3 +921,31 @@ func TestCommandPlanetRouteRemove(t *testing.T) {
})
}
}
func TestMultipleCommands(t *testing.T) {
e := newExecutor()
r := setupRouterExecutor(e)
payload := &rest.Command{
Actor: commandDefaultActor,
Commands: []json.RawMessage{
encodeCommand(&rest.CommandRaceRelation{
CommandMeta: rest.CommandMeta{Type: rest.CommandTypeRaceRelation},
Acceptor: "Opponent",
Relation: "PEACE",
}),
encodeCommand(&rest.CommandRaceVote{
CommandMeta: rest.CommandMeta{Type: rest.CommandTypeRaceVote},
Acceptor: "Opponent",
}),
},
}
w := httptest.NewRecorder()
req, _ := http.NewRequest(apiCommandMethod, apiCommandPath, asBody(payload))
r.ServeHTTP(w, req)
assert.Equal(t, commandNoErrorsStatus, w.Code, w.Body)
assert.Equal(t, 2, e.(*dummyExecutor).CommandsExecuted)
}