Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
mock_server.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2022 Minetest core developers & community
4
5#pragma once
6
7#include "server.h"
8#include "server/mods.h"
9#include "scripting_server.h"
10
11class MockServer : public Server
12{
13public:
14 /* Set `path_world` to a real existing folder if you plan to initialize scripting! */
15 MockServer(const std::string &path_world = "fakepath") :
16 Server(path_world, SubgameSpec("fakespec", "fakespec"), true,
17 Address(), true, nullptr
18 )
19 {}
20
21 /*
22 * Use this in unit tests to create scripting.
23 * Note that you still need to call script->loadBuiltin() and don't forget
24 * a try-catch for `ModError`.
25 */
27 m_script = std::make_unique<ServerScripting>(this);
28 m_modmgr = std::make_unique<ServerModManager>(nullptr);
29 }
30
31 void start() = delete;
32 void stop() = delete;
33
34private:
35 void SendChatMessage(session_t peer_id, const ChatMessage &message) {}
36};
Definition address.h:28
Definition mock_server.h:12
void start()=delete
void SendChatMessage(session_t peer_id, const ChatMessage &message)
Definition mock_server.h:35
MockServer(const std::string &path_world="fakepath")
Definition mock_server.h:15
void stop()=delete
void createScripting()
Definition mock_server.h:26
Definition server.h:167
std::unique_ptr< ServerModManager > m_modmgr
Definition server.h:472
std::unique_ptr< ServerScripting > m_script
Definition server.h:469
u16 session_t
Definition networkprotocol.h:22
Definition chatmessage.h:20
Definition subgames.h:15