You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
35 lines
1.0 KiB
#ifndef _TR_TEST_SERVER_CONTEXT_HPP_ |
|
#define _TR_TEST_SERVER_CONTEXT_HPP_ |
|
|
|
#include <Catch/catch.hpp> |
|
#include <json.hpp> |
|
#include <sstream> |
|
#include <unordered_map> |
|
|
|
class TestRequest { |
|
public: |
|
std::stringstream content; |
|
}; |
|
|
|
class TestResponse : public std::stringstream { |
|
public: |
|
std::string buffer; |
|
std::unordered_map<std::string, std::string> headers_; |
|
std::string string(); |
|
std::string message(); |
|
std::string code(); |
|
std::string content(); |
|
const std::unordered_map<std::string, std::string> &headers(); |
|
}; |
|
|
|
class CommonResponse { |
|
public: |
|
static void service_unavailable(std::shared_ptr<TestResponse> response); |
|
static void ok(std::shared_ptr<TestResponse> response, const nlohmann::json &data); |
|
static void bad_request(std::shared_ptr<TestResponse> response); |
|
static void accepted(std::shared_ptr<TestResponse> response); |
|
static void no_content(std::shared_ptr<TestResponse> response); |
|
static void created(std::shared_ptr<TestResponse> response, std::shared_ptr<TestRequest> request, const std::string &location); |
|
}; |
|
|
|
#endif |