feat: game order api methods
This commit is contained in:
@@ -3,6 +3,7 @@ package repo_test
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"galaxy/model/order"
|
||||
|
||||
@@ -18,7 +19,11 @@ func TestSaveOrder(t *testing.T) {
|
||||
s, err := fs.NewFileStorage(root)
|
||||
assert.NoError(t, err)
|
||||
id := uuid.New()
|
||||
o := &order.Order{
|
||||
gameID := uuid.New()
|
||||
now := time.Now().UTC().UnixMilli()
|
||||
o := &order.UserGamesOrder{
|
||||
GameID: gameID,
|
||||
UpdatedAt: now,
|
||||
Commands: []order.DecodableCommand{
|
||||
&order.CommandRaceVote{
|
||||
CommandMeta: order.CommandMeta{
|
||||
@@ -87,17 +92,19 @@ func TestSaveOrder(t *testing.T) {
|
||||
LoadOrderTest(t, s, root, turn, id, o)
|
||||
}
|
||||
|
||||
func LoadOrderTest(t *testing.T, s repo.Storage, root string, turn uint, id uuid.UUID, expected *order.Order) {
|
||||
func LoadOrderTest(t *testing.T, s repo.Storage, root string, turn uint, id uuid.UUID, expected *order.UserGamesOrder) {
|
||||
o, ok, err := repo.LoadOrder_T(s, turn, id)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, ok)
|
||||
assert.Len(t, o.Commands, 5)
|
||||
assert.Equal(t, expected.GameID, o.GameID)
|
||||
assert.Equal(t, expected.UpdatedAt, o.UpdatedAt)
|
||||
assert.ElementsMatch(t, expected.Commands, o.Commands)
|
||||
|
||||
CommandResultTest(t, o)
|
||||
}
|
||||
|
||||
func CommandResultTest(t *testing.T, o *order.Order) {
|
||||
func CommandResultTest(t *testing.T, o *order.UserGamesOrder) {
|
||||
assert.NotEmpty(t, o.Commands)
|
||||
for i := range o.Commands {
|
||||
if v, ok := order.AsCommand[*order.CommandRaceVote](o.Commands[i]); ok {
|
||||
|
||||
Reference in New Issue
Block a user