Files

39 lines
1.1 KiB
C++
Raw Permalink Normal View History

#pragma once
// Test client: drives the real Application (routing, middleware, views, DI,
// error mapping, in-memory DB) without sockets, plus a cookie jar and frozen
// time hook. Gap: real test client in 08-clients-openapi.md owns fixtures,
// DB resets, and time freezing.
#include <map>
#include <memory>
#include <string>
#include "App.hpp"
namespace molo::example::fw {
class TestClient {
public:
explicit TestClient(std::shared_ptr<Application> app);
Response get(const std::string& path);
Response post(const std::string& path, const std::string& body = "",
const std::string& content_type = "text/plain");
Response request(Method method, const std::string& path,
const std::string& body = "",
const std::map<std::string, std::string>& headers =
{});
void freeze_time(const std::string& iso);
const std::string& frozen_time() const;
void clear_cookies();
private:
std::shared_ptr<Application> app_;
std::map<std::string, std::string> jar_;
std::string frozen_time_;
};
} // namespace molo::example::fw