Files

27 lines
876 B
C++
Raw Permalink Normal View History

// Route: GET /health (probe plus real-HTTP loopback round-trip)
#include "support/Assert.hpp"
#include "fw/Server.hpp"
using namespace molo::example::test;
int main() {
Fixture f;
auto res = f.client->get("/health");
check(res.status == 200, "status 200");
check(contains(res.body, "\"status\":\"ok\""), "ok body");
molo::example::fw::Server server(f.app);
check(server.start("127.0.0.1", 0), "loopback server starts");
std::string wire = molo::example::fw::http_roundtrip(
"127.0.0.1", server.port(),
"GET /health HTTP/1.1\r\nHost: x\r\nConnection: close\r\n\r\n");
check(contains(wire, "200 OK"), "real HTTP status line");
check(contains(wire, "\"status\":\"ok\""), "real HTTP body");
server.stop();
auto missing = f.client->get("/no-such-route");
check(missing.status == 404, "unknown route is 404");
return finish("health");
}