summaryrefslogtreecommitdiff
path: root/http/test_stream.hpp
blob: dbbf04d2c6c7750f560aba29f098246beeed9f59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/beast/_experimental/test/stream.hpp>

namespace crow
{

/*
A test class that simulates a socket by wrapping the beast test stream

Additionally it adds remote_endpoint to allow testing of TCP-specific behaviors
*/
struct TestStream : public boost::beast::test::stream
{
    explicit TestStream(boost::asio::io_context& io) :
        boost::beast::test::stream(io)
    {}

    using endpoint = boost::asio::ip::tcp::endpoint;
    // NOLINTNEXTLINE(readability-identifier-naming)
    static endpoint remote_endpoint(boost::system::error_code& ec)
    {
        ec = {};
        return {};
    }
};

} // namespace crow