Add export to file (#58)

* Initial addition of a game exporter

* Fix snake state bug, remove test logs, fix final output line being empty

* Ignore test JSONL file

* Added explanation for design decision on the you key in SnakeResponse

* Adjust gitignore to be more generic

* Retain consistency in usage of pointer

* Re-word explanation to refer to requests instead of responses

* Remove unnecessary nil check

* Check error returned by WriteString

* Change file permissions for output file

* Initialise gameexporter regardless of whether output is requested

* Print error and exit if export to file fails

* Added another comment explaining reasoning around export checks

* Fixed broken test due to changed return type
This commit is contained in:
Simon Agius Muscat 2021-12-02 18:59:20 +01:00 committed by GitHub
parent 4a9dbbcaef
commit 142a5a6ecf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 184 additions and 38 deletions

View file

@ -35,7 +35,8 @@ func TestGetIndividualBoardStateForSnake(t *testing.T) {
s1State.ID: s1State,
s2State.ID: s2State,
}
requestBody := getIndividualBoardStateForSnake(state, s1State, snakeStates, &rules.StandardRuleset{})
snakeRequest := getIndividualBoardStateForSnake(state, s1State, snakeStates, &rules.StandardRuleset{})
requestBody := serialiseSnakeRequest(snakeRequest)
test.RequireJSONMatchesFixture(t, "testdata/snake_request_body.json", string(requestBody))
}