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

24 lines
1.1 KiB
C++
Raw Normal View History

// Route: /operability/shedder (low priority shed first)
#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/shedder").status == 200, "status 200");
f.client->post("/operability/shedder/enter", "priority=low", kForm);
f.client->post("/operability/shedder/enter", "priority=low", kForm);
auto low = f.client->post("/operability/shedder/enter", "priority=low", kForm);
check(contains(low.body, "shed"), "third low request shed");
auto high = f.client->post("/operability/shedder/enter", "priority=high", kForm);
check(contains(high.body, "accepted"), "high priority still accepted");
auto bad = f.client->post("/operability/shedder/enter", "priority=urgent", kForm);
check(bad.status == 422 && contains(bad.body, "must be one of: low, high"), "422 inline error");
check(!contains(bad.body, "{\"errors\""), "no raw json in page");
check(contains(f.client->get("/operability/shedder").body, "3/3"), "side effect: inflight 3/3");
return finish("operability/shedder");
}