Пример #1
0
func TestSaveAndGetGameState(t *testing.T) {
	u := NewUserForTest(t)
	userRow := u.signupNewUserRowForTest(t)
	gameStateDB := newGameStateDBForTest(t)

	// Save game state
	originalGameState := libgame.NewGame()
	err := gameStateDB.SaveGameState(nil, *userRow, originalGameState)
	assert.Nil(t, err)

	// Retrieved saved game state
	retrievedGameState, err := gameStateDB.GetGameState(*userRow)
	assert.Nil(t, err)
	assert.Equal(t, originalGameState, *retrievedGameState)
}
Пример #2
0
// HandleNewGameRequest saves a new GameState to the DB
//
// We respond just like a /state request
func HandleNewGameRequest(w http.ResponseWriter, r *http.Request) {
	gameState := libgame.NewGame()
	saveGameStateAndRespond(w, r, gameState)
}