Files
galaxy-game/internal/router/router_helper_test.go
T
2026-02-10 18:31:53 +03:00

40 lines
806 B
Go

package router_test
import (
"encoding/json"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"github.com/iliadenisov/galaxy/internal/model/rest"
"github.com/iliadenisov/galaxy/internal/router"
"github.com/iliadenisov/galaxy/internal/router/handler"
)
type dummyExecutor struct {
}
func (e *dummyExecutor) Execute(cmd ...handler.Command) error {
return nil
}
func (e *dummyExecutor) GenerateGame(races []string) (uuid.UUID, error) {
return uuid.New(), nil
}
func (e *dummyExecutor) GameState() (rest.StateResponse, error) {
return rest.StateResponse{}, nil
}
func setupRouter() *gin.Engine {
gin.SetMode(gin.TestMode)
return router.SetupRouter(&dummyExecutor{})
}
func encodeCommand(cmd any) json.RawMessage {
v, err := json.Marshal(cmd)
if err != nil {
panic(err)
}
return v
}