26 lines
658 B
Go
26 lines
658 B
Go
package game_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/iliadenisov/galaxy/pkg/game"
|
|
"github.com/iliadenisov/galaxy/pkg/util"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestComposeGame(t *testing.T) {
|
|
root, cleanup := util.CreateWorkDir(t)
|
|
defer cleanup()
|
|
players := 20
|
|
races := make([]string, players)
|
|
for i := range players {
|
|
races[i] = fmt.Sprintf("race_%02d", i)
|
|
}
|
|
_, err := game.ComposeGame(func(p *game.Param) { p.StoragePath = root }, races)
|
|
assert.NoError(t, err)
|
|
_, err = game.ComposeGame(func(p *game.Param) { p.StoragePath = root }, races)
|
|
assert.Error(t, err)
|
|
assert.ErrorContains(t, err, "state for turn 0 already saved")
|
|
}
|