fix: game order api & tests
This commit is contained in:
@@ -32,15 +32,40 @@ func id() string {
|
||||
|
||||
type dummyExecutor struct {
|
||||
CommandsExecuted int
|
||||
|
||||
// ValidateOrderResult, when non-nil, is returned from ValidateOrder.
|
||||
// When nil, ValidateOrder synthesises an order from the received args
|
||||
// so the response body is non-empty for status assertions.
|
||||
ValidateOrderResult *order.UserGamesOrder
|
||||
ValidateOrderErr error
|
||||
|
||||
// FetchOrder controls and observes calls to FetchOrder.
|
||||
FetchOrderActor string
|
||||
FetchOrderTurn uint
|
||||
FetchOrderResult *order.UserGamesOrder
|
||||
FetchOrderOK bool
|
||||
FetchOrderErr error
|
||||
}
|
||||
|
||||
func (e *dummyExecutor) ValidateOrder(actor string, cmd ...order.DecodableCommand) (*order.UserGamesOrder, error) {
|
||||
e.CommandsExecuted = len(cmd)
|
||||
return nil, nil
|
||||
if e.ValidateOrderErr != nil {
|
||||
return nil, e.ValidateOrderErr
|
||||
}
|
||||
if e.ValidateOrderResult != nil {
|
||||
return e.ValidateOrderResult, nil
|
||||
}
|
||||
return &order.UserGamesOrder{
|
||||
GameID: uuid.New(),
|
||||
UpdatedAt: 1,
|
||||
Commands: append([]order.DecodableCommand(nil), cmd...),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (e *dummyExecutor) FetchOrder(actor string, turn uint) (*order.UserGamesOrder, bool, error) {
|
||||
return nil, true, nil
|
||||
e.FetchOrderActor = actor
|
||||
e.FetchOrderTurn = turn
|
||||
return e.FetchOrderResult, e.FetchOrderOK, e.FetchOrderErr
|
||||
}
|
||||
|
||||
func (e *dummyExecutor) Execute(command ...handler.Command) error {
|
||||
|
||||
Reference in New Issue
Block a user