feat(workflow): example covers security, platform, enterprise and resilience features
105 route tests, matrix crawl, spec and README updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// Route: /data/transaction (commit and rollback)
|
||||
#include "support/Assert.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
using molo::example::fw::Method;
|
||||
|
||||
static const char* kForm = "application/x-www-form-urlencoded";
|
||||
|
||||
int main() {
|
||||
Fixture f;
|
||||
check(f.client->get("/data/transaction").status == 200, "status 200");
|
||||
auto ok = f.client->post("/data/transaction/transfer", "amount=30", kForm);
|
||||
check(contains(ok.body, "committed"), "commit");
|
||||
check(f.services.sqlite != nullptr, "fixture alive");
|
||||
auto fail = f.client->post("/data/transaction/transfer", "amount=10&fail_after_debit=1", kForm);
|
||||
check(contains(fail.body, "rolled back: failure after debit"), "failure rolls back");
|
||||
auto over = f.client->post("/data/transaction/transfer", "amount=500", kForm);
|
||||
check(contains(over.body, "rolled back: insufficient funds"), "overdraft rolls back");
|
||||
auto json = f.client->request(Method::Post, "/data/transaction/transfer", "{\"amount\":\"1\"}", {{"Content-Type", "application/json"}});
|
||||
check(json.status == 200 && contains(json.body, "\"alice\":\"69\""), "alice 100-30-1; rollbacks changed nothing");
|
||||
check(contains(json.body, "\"rollbacks\":\"2\"") && contains(json.body, "\"commits\":\"2\""), "side effect: counters");
|
||||
auto same = f.client->post("/data/transaction/transfer", "from=bob&to=bob&amount=5", kForm);
|
||||
check(same.status == 422 && contains(same.body, "must differ"), "422 same account");
|
||||
check(f.client->post("/data/transaction/transfer", "amount=0", kForm).status == 422, "422 amount limit");
|
||||
return finish("data/transaction");
|
||||
}
|
||||
Reference in New Issue
Block a user