Files
moloapp/tests/example/pubsub/publish_test.cpp
T

21 lines
733 B
C++
Raw Normal View History

// Route: /pubsub/publish
#include "support/Assert.hpp"
using namespace molo::example::test;
int main() {
Fixture f;
int seen = 0;
f.services.pubsub->subscribe("news",
[&](const std::string&) { ++seen; });
auto pub = f.client->post("/pubsub/publish",
"{\"topic\":\"news\",\"message\":\"hi\"}",
"application/json");
check(pub.status == 200, "publish status 200");
check(contains(pub.body, "\"delivered\":1"), "one subscriber reached");
check(seen == 1, "side effect: listener ran");
auto hist = f.client->get("/pubsub/publish?topic=news");
check(contains(hist.body, "hi"), "history kept");
return finish("pubsub/publish");
}