feat: Initialized Project
Build / test-and-build (scribblers-linux-x64, ubuntu-latest) (push) Has been cancelled
Build / test-and-build (scribblers-macos-x64, macos-latest) (push) Has been cancelled
Build / test-and-build (scribblers-x64.exe, windows-latest) (push) Has been cancelled

This commit is contained in:
2026-05-09 09:36:38 +03:30
commit ff300a5e84
121 changed files with 46171 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
package state
import (
"testing"
"github.com/stretchr/testify/require"
"medad.fun/internal/config"
"medad.fun/internal/game"
)
//nolint:paralleltest //this test is very stateful
func TestAddAndRemove(t *testing.T) {
require.Empty(t, lobbies, "Lobbies should be empty when test starts")
createLobby := func() *game.Lobby {
player, lobby, err := game.CreateLobby("", "player", "dutch", true, 100, 10, 10, 3, 3, 1, nil, game.ChillScoring)
require.NoError(t, err)
lobby.OnPlayerDisconnect(player)
return lobby
}
lobbyA := createLobby()
lobbyB := createLobby()
lobbyC := createLobby()
AddLobby(lobbyA)
AddLobby(lobbyB)
AddLobby(lobbyC)
require.NotNil(t, GetLobby(lobbyA.LobbyID))
require.NotNil(t, GetLobby(lobbyB.LobbyID))
require.NotNil(t, GetLobby(lobbyC.LobbyID))
RemoveLobby(lobbyB.LobbyID)
require.Nil(t, GetLobby(lobbyB.LobbyID), "Lobby B should have been deleted.")
require.NotNil(t, GetLobby(lobbyA.LobbyID), "Lobby A shouldn't have been deleted.")
require.NotNil(t, GetLobby(lobbyC.LobbyID), "Lobby C shouldn't have been deleted.")
require.Len(t, lobbies, 2)
cleanupRoutineLogic(&config.LobbyCleanup{})
require.Empty(t, lobbies)
}