Refactor rulesets into smaller composable operations In order to mix up the functionality from different rulesets like Solo, Royale, etc. the code in these classes needs to be broken up into small functions that can be composed in a pipeline to make a custom game mode.
27 lines
782 B
Go
27 lines
782 B
Go
package client
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/BattlesnakeOfficial/rules"
|
|
"github.com/BattlesnakeOfficial/rules/test"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestBuildSnakeRequestJSON(t *testing.T) {
|
|
snakeRequest := exampleSnakeRequest()
|
|
data, err := json.MarshalIndent(snakeRequest, "", " ")
|
|
require.NoError(t, err)
|
|
|
|
test.RequireJSONMatchesFixture(t, "testdata/snake_request.json", string(data))
|
|
}
|
|
|
|
func TestBuildSnakeRequestJSONEmptyRulesetSettings(t *testing.T) {
|
|
snakeRequest := exampleSnakeRequest()
|
|
snakeRequest.Game.Ruleset.Settings = rules.Settings{}
|
|
data, err := json.MarshalIndent(snakeRequest, "", " ")
|
|
require.NoError(t, err)
|
|
|
|
test.RequireJSONMatchesFixture(t, "testdata/snake_request_empty_ruleset_settings.json", string(data))
|
|
}
|