From 9cf4500878edf6c4f64b478c4e7feda92d5bee76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Mon, 1 May 2017 23:23:09 +0200 Subject: [PATCH] update test and add route --- toREST/src/main.cxx | 5 ++++- toREST/tests/torrents_test.cpp | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/toREST/src/main.cxx b/toREST/src/main.cxx index 52ebbe6..85c4151 100644 --- a/toREST/src/main.cxx +++ b/toREST/src/main.cxx @@ -40,9 +40,12 @@ int main(int argc, char *argv[]) { tr::session::patch(session, resp, req); }; - http_server.resource["^/session/torrents(\\?.*)?\\/?$"]["GET"] = [&session](std::shared_ptr resp, std::shared_ptr req) { + http_server.resource["^/session/torrents(\\?.*)?\\/?$"]["GET"] = [&](std::shared_ptr resp, std::shared_ptr req) { tr::session::torrents::get(session, resp, req); }; + http_server.resource["^/session/torrents(\\?.*)?\\/?$"]["PATCH"] = [&](std::shared_ptr resp, std::shared_ptr req) { + + }; std::thread server_thread([&http_server]() { http_server.start(); diff --git a/toREST/tests/torrents_test.cpp b/toREST/tests/torrents_test.cpp index 3e6f32a..1c0da47 100644 --- a/toREST/tests/torrents_test.cpp +++ b/toREST/tests/torrents_test.cpp @@ -19,12 +19,12 @@ SCENARIO("We are running a GET /session/torrents resource") { } GIVEN("the server is working properly") { torrent_session.valid = true; - AND_WHEN("the session is paused the paused field is set to true") { - torrent_session.paused = true; + AND_WHEN("the session the session has no torrents") { 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()}}); } + } } } \ No newline at end of file