craban/server/services/store/game_test.go
2021-09-13 21:58:52 +02:00

30 lines
731 B
Go

package store
import (
"testing"
"git.ctrlz.es/mgdelacroix/craban/model"
"github.com/stretchr/testify/require"
)
func TestCreateGame(t *testing.T) {
th, teardown := NewTestHelper(t)
defer teardown()
user := th.NewUser()
gameName := "Awesome Game"
game, err := th.store.Game().Create(gameName, user.ID)
require.NoError(t, err)
require.NotZero(t, game.ID)
require.Equal(t, gameName, game.Name)
require.Equal(t, user.ID, game.UserID)
gameMembers, err := th.store.Game().GetGameMembers(game.ID)
require.NoError(t, err)
require.Len(t, gameMembers, 1)
require.Equal(t, game.ID, gameMembers[0].GameID)
require.Equal(t, user.ID, gameMembers[0].UserID)
require.Equal(t, model.RoleGameMaster, gameMembers[0].Role)
}