[Server] Share one in-memory database interface across the server tests

This commit is contained in:
Lukas Brübach 2026-11-10 03:06:08 +01:00
parent 5565f21b39
commit 1173763af4
10 changed files with 200 additions and 170 deletions

View file

@ -7,8 +7,8 @@
#include "game/role_info.h"
#include "game/server_game.h"
#include "libcockatrice/protocol/pb/response.pb.h"
#include "libcockatrice/server/dev/servatrice_in_memory_database_interface.h"
#include "server.h"
#include "server_database_interface.h"
#include "server_room.h"
#include <QList>
@ -23,43 +23,12 @@ RNG_Abstract *rng = nullptr; // referenced by the server_remote library
namespace
{
class MockDatabaseInterface : public Server_DatabaseInterface
{
public:
AuthenticationResult checkUserPassword(Server_ProtocolHandler *,
const QString &,
const QString &,
const QString &,
QString &,
int &,
bool) override
{
return NotLoggedIn;
}
int getNextReplayId() override
{
return 1;
}
int getNextGameId() override
{
return 1;
}
int getActiveUserCount(QString) override
{
return 0;
}
ServerInfo_User getUserData(const QString &, bool) override
{
return ServerInfo_User();
}
};
class FakeServer : public Server
{
public:
FakeServer()
{
setDatabaseInterface(new MockDatabaseInterface());
setDatabaseInterface(new Servatrice_InMemoryDatabaseInterface());
}
};