Files
moloapp/tests/example/operability/bulkhead_test.cpp
T

25 lines
1.2 KiB
C++
Raw Normal View History

// Route: /operability/bulkhead (2 slots, queue of 1, then reject)
#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("/operability/bulkhead").status == 200, "status 200");
auto a = f.client->post("/operability/bulkhead/acquire", "", kForm);
check(contains(a.body, ">admitted<") || contains(a.body, "admitted"), "first admitted");
f.client->post("/operability/bulkhead/acquire", "", kForm);
auto q = f.client->post("/operability/bulkhead/acquire", "", kForm);
check(contains(q.body, "queued"), "third queued");
auto r = f.client->post("/operability/bulkhead/acquire", "", kForm);
check(contains(r.body, "rejected: compartment full"), "fourth rejected (limit)");
check(contains(r.body, "2/2"), "side effect: active slots full");
check(f.client->post("/operability/bulkhead/nope", "", kForm).status == 404, "404 unknown action");
for (int i = 0; i < 3; ++i) f.client->post("/operability/bulkhead/release", "", kForm);
check(contains(f.client->post("/operability/bulkhead/release", "", kForm).body, "nothing to release"), "empty release is reported");
return finish("operability/bulkhead");
}