mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-11 04:23:29 -08:00
[Tests] Migrate server tests to the shared fixture
Replace the remaining private MockDatabaseInterface/FakeServer copies in the forced-password, room-channel, movecard, and random-reveal tests with InMemoryServer_DatabaseInterface and ServerTestFixture. The room-channel test keeps its log assertions against the shared logEntries; the forced-password test seeds its moderator user and auth result through the fixture knobs. Delete movecard_tests/server_test_helpers.h.
This commit is contained in:
parent
2187e47a60
commit
7b8558c695
8 changed files with 34 additions and 167 deletions
|
|
@ -6,6 +6,9 @@ cockatrice_add_test(
|
|||
LIBS
|
||||
libcockatrice_network_server_remote
|
||||
libcockatrice_rng
|
||||
testsupport_server
|
||||
INCLUDE_DIRS
|
||||
${CMAKE_SOURCE_DIR}/tests
|
||||
LABELS
|
||||
server
|
||||
)
|
||||
|
|
@ -18,6 +21,9 @@ cockatrice_add_test(
|
|||
LIBS
|
||||
libcockatrice_network_server_remote
|
||||
libcockatrice_rng
|
||||
testsupport_server
|
||||
INCLUDE_DIRS
|
||||
${CMAKE_SOURCE_DIR}/tests
|
||||
LABELS
|
||||
server
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "server_abstractuserinterface.h"
|
||||
#include "server_response_containers.h"
|
||||
#include "server_room.h"
|
||||
#include "server_test_helpers.h"
|
||||
#include "support/server_test_fixture.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <libcockatrice/protocol/pb/game_event_container.pb.h>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "libcockatrice/protocol/pb/serverinfo_zone.pb.h"
|
||||
#include "server_response_containers.h"
|
||||
#include "server_room.h"
|
||||
#include "server_test_helpers.h"
|
||||
#include "support/server_test_fixture.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#include "server.h"
|
||||
#include "server_database_interface.h"
|
||||
|
||||
class MockDatabaseInterface : public Server_DatabaseInterface
|
||||
{
|
||||
public:
|
||||
AuthenticationResult checkUserPassword(Server_ProtocolHandler *,
|
||||
const QString &,
|
||||
const QString &,
|
||||
const QString &,
|
||||
QString &,
|
||||
int &,
|
||||
bool) override
|
||||
{
|
||||
return NotLoggedIn;
|
||||
}
|
||||
ServerInfo_User getUserData(const QString &, bool) override
|
||||
{
|
||||
return ServerInfo_User();
|
||||
}
|
||||
int getNextGameId() override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int getNextReplayId() override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int getActiveUserCount(QString) override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
class FakeServer : public Server
|
||||
{
|
||||
public:
|
||||
FakeServer()
|
||||
{
|
||||
setDatabaseInterface(new MockDatabaseInterface());
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue