Files
moloapp/tests/example/tenancy/metrics_test.cpp
T

19 lines
818 B
C++
Raw Normal View History

// Route: GET /tenancy/metrics (per-tenant counters)
#include "support/Assert.hpp"
using namespace molo::example::test;
using molo::example::fw::Method;
int main() {
Fixture f;
check(f.client->get("/tenancy/metrics").status == 200, "empty ok");
f.client->request(Method::Get, "/tenancy/data", "", {{"X-Tenant-ID", "acme"}});
f.client->request(Method::Get, "/tenancy/data", "", {{"X-Tenant-ID", "acme"}});
f.client->request(Method::Get, "/tenancy/data", "", {{"X-Tenant-ID", "globex"}});
auto m = f.client->get("/tenancy/metrics");
check(contains(m.body, "\"acme\":{\"data.list\":2}"), "acme counted twice");
check(contains(m.body, "\"globex\":{\"data.list\":1}"), "globex counted once");
check(f.client->post("/tenancy/metrics").status == 405, "405 on post");
return finish("tenancy/metrics");
}