-
Notifications
You must be signed in to change notification settings - Fork 1
/
ControllerTest.cpp
30 lines (24 loc) · 977 Bytes
/
ControllerTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#define CATCH_CONFIG_MAIN
#include "Server.hpp"
#include "TestClient.hpp"
#include "TestRunner.hpp"
#include <cstdlib>
#include "catch2/catch.hpp"
#include "oatpp/web/client/HttpRequestExecutor.hpp"
TEST_CASE("Index returns 200", "[Controller]") {
TestRunner<Server, TestClient>::run([](std::shared_ptr<TestClient> client) {
auto response = client->getRoot();
REQUIRE(response->getStatusCode() == 200);
auto value = response->readBodyToString();
REQUIRE(value == "");
}, std::chrono::minutes(10));
}
TEST_CASE("File transfer succeeds", "[Controller]") {
std::system(R"#(echo '{"hello":"world"}'>/tmp/tmp.json)#");
TestRunner<Server, TestClient>::run([](std::shared_ptr<TestClient> client) {
auto response = client->getStatic();
REQUIRE(response->getStatusCode() == 200);
auto value = response->readBodyToString();
REQUIRE_THAT(value.get()->std_str(), Catch::StartsWith(R"#({"hello":"world"})#"));
}, std::chrono::minutes(10));
}