Files

25 lines
1.0 KiB
C++
Raw Permalink Normal View History

// Route: /orm/users (dual backends, auto-sync self-healing)
#include "support/Assert.hpp"
using namespace molo::example::test;
int main() {
Fixture f;
auto first = f.client->get("/orm/users?backend=sqlite");
check(first.status == 200, "sqlite status 200");
check(contains(first.body, "\"healed\":true"), "table auto-created");
auto insert = f.client->post("/orm/users?backend=sqlite",
"{\"name\":\"ada\"}", "application/json");
check(insert.status == 201, "insert status 201");
auto widen = f.client->post("/orm/users?backend=sqlite",
"{\"name\":\"g\",\"email\":\"g@x.io\"}",
"application/json");
check(contains(widen.body, "auto-added column email"),
"new column self-healed");
auto pg = f.client->get("/orm/users?backend=postgres");
check(contains(pg.body, "\"backend\":\"postgres\""),
"postgres backend selected");
check(!f.services.sqlite->tables().empty(), "side effect: table exists");
return finish("orm/users");
}