2024-10-28 15:57:39 +01:00
|
|
|
// Luanti
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
// Copyright (C) 2022 Minetest core developers & community
|
2022-09-27 22:22:11 +02:00
|
|
|
|
2022-09-29 22:16:29 +02:00
|
|
|
#pragma once
|
|
|
|
|
2024-03-03 19:51:49 +01:00
|
|
|
#include "server.h"
|
2024-03-12 14:13:24 +01:00
|
|
|
#include "server/mods.h"
|
|
|
|
#include "scripting_server.h"
|
2022-09-27 22:22:11 +02:00
|
|
|
|
|
|
|
class MockServer : public Server
|
|
|
|
{
|
|
|
|
public:
|
2024-03-12 14:13:24 +01:00
|
|
|
/* Set `path_world` to a real existing folder if you plan to initialize scripting! */
|
2024-01-10 19:10:58 +01:00
|
|
|
MockServer(const std::string &path_world = "fakepath") :
|
|
|
|
Server(path_world, SubgameSpec("fakespec", "fakespec"), true,
|
|
|
|
Address(), true, nullptr
|
|
|
|
)
|
2022-09-27 22:22:11 +02:00
|
|
|
{}
|
|
|
|
|
2024-03-12 14:13:24 +01:00
|
|
|
/*
|
|
|
|
* Use this in unit tests to create scripting.
|
|
|
|
* Note that you still need to call script->loadBuiltin() and don't forget
|
|
|
|
* a try-catch for `ModError`.
|
|
|
|
*/
|
|
|
|
void createScripting() {
|
|
|
|
m_script = std::make_unique<ServerScripting>(this);
|
|
|
|
m_modmgr = std::make_unique<ServerModManager>(nullptr);
|
|
|
|
}
|
|
|
|
|
2024-03-03 19:51:49 +01:00
|
|
|
void start() = delete;
|
|
|
|
void stop() = delete;
|
|
|
|
|
2022-09-27 22:22:11 +02:00
|
|
|
private:
|
|
|
|
void SendChatMessage(session_t peer_id, const ChatMessage &message) {}
|
|
|
|
};
|