Fix unstable unittest (#1102)

Properly mock wsbase
This commit is contained in:
cyan317
2024-01-15 12:06:14 +00:00
committed by GitHub
parent ce86572274
commit 350a45e7e2
12 changed files with 140 additions and 261 deletions

View File

@@ -20,29 +20,21 @@
#pragma once
#include "util/Taggable.h"
#include "util/config/Config.h"
#include "web/interface/ConnectionBase.h"
#include <boost/beast/http/status.hpp>
#include <gmock/gmock.h>
#include <memory>
#include <string>
struct MockSession : public web::ConnectionBase {
std::string message;
void
send(std::shared_ptr<std::string> msg_type) override
{
message += std::string(msg_type->data());
}
MOCK_METHOD(void, send, (std::shared_ptr<std::string>), (override));
MOCK_METHOD(void, send, (std::string&&, boost::beast::http::status), (override));
util::TagDecoratorFactory tagDecoratorFactory{util::Config{}};
void
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
send(std::string&& msg, boost::beast::http::status = boost::beast::http::status::ok) override
{
message += msg;
}
MockSession(util::TagDecoratorFactory const& factory) : web::ConnectionBase(factory, "")
MockSession() : web::ConnectionBase(tagDecoratorFactory, "")
{
}
};