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
+12 -2
View File
@@ -11,9 +11,11 @@ import (
)
type dummyExecutor struct {
CommandsExecuted int
}
func (e *dummyExecutor) Execute(cmd ...handler.Command) error {
func (e *dummyExecutor) Execute(command ...handler.Command) error {
e.CommandsExecuted = len(command)
return nil
}
@@ -26,8 +28,16 @@ func (e *dummyExecutor) GameState() (rest.StateResponse, error) {
}
func setupRouter() *gin.Engine {
return setupRouterExecutor(newExecutor())
}
func setupRouterExecutor(e handler.CommandExecutor) *gin.Engine {
gin.SetMode(gin.TestMode)
return router.SetupRouter(&dummyExecutor{})
return router.SetupRouter(e)
}
func newExecutor() handler.CommandExecutor {
return &dummyExecutor{}
}
func encodeCommand(cmd any) json.RawMessage {