Browse Source

update test and add route

master
Jørgen Lien Sellæg 9 years ago
parent
commit
9cf4500878
  1. 5
      toREST/src/main.cxx
  2. 6
      toREST/tests/torrents_test.cpp

5
toREST/src/main.cxx

@ -40,9 +40,12 @@ int main(int argc, char *argv[]) {
tr::session::patch(session, resp, req); tr::session::patch(session, resp, req);
}; };
http_server.resource["^/session/torrents(\\?.*)?\\/?$"]["GET"] = [&session](std::shared_ptr<HttpServer::Response> resp, std::shared_ptr<HttpServer::Request> req) { http_server.resource["^/session/torrents(\\?.*)?\\/?$"]["GET"] = [&](std::shared_ptr<HttpServer::Response> resp, std::shared_ptr<HttpServer::Request> req) {
tr::session::torrents::get(session, resp, req); tr::session::torrents::get(session, resp, req);
}; };
http_server.resource["^/session/torrents(\\?.*)?\\/?$"]["PATCH"] = [&](std::shared_ptr<HttpServer::Response> resp, std::shared_ptr<HttpServer::Request> req) {
};
std::thread server_thread([&http_server]() { std::thread server_thread([&http_server]() {
http_server.start(); http_server.start();

6
toREST/tests/torrents_test.cpp

@ -19,12 +19,12 @@ SCENARIO("We are running a GET /session/torrents resource") {
} }
GIVEN("the server is working properly") { GIVEN("the server is working properly") {
torrent_session.valid = true; torrent_session.valid = true;
AND_WHEN("the session is paused the paused field is set to true") { AND_WHEN("the session the session has no torrents") {
torrent_session.paused = true;
tr::session::torrents::get(torrent_session, response, request); tr::session::torrents::get(torrent_session, response, request);
THEN("the server should reply with resource data") { THEN("the server should reply with an empty array") {
CommonResponse::ok(response, {{"torrents", nlohmann::json::array()}}); CommonResponse::ok(response, {{"torrents", nlohmann::json::array()}});
} }
} }
} }
} }
Loading…
Cancel
Save