From 6eb6928f8e12e9d6b05a2c78e2e6100d7babfeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Sat, 13 May 2017 23:18:50 +0200 Subject: [PATCH] cleanup: move delete test to bottom of file --- toREST/tests/torrents_test.cpp | 67 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/toREST/tests/torrents_test.cpp b/toREST/tests/torrents_test.cpp index df2ed81..44d4fb0 100644 --- a/toREST/tests/torrents_test.cpp +++ b/toREST/tests/torrents_test.cpp @@ -49,40 +49,6 @@ SCENARIO("We are running a GET /session/torrents resource") { const std::string torrent_id = "c0b0a90089710812fe8c37385a4cc2978eabf3e8"; - -SCENARIO("We are running a DELETE /session/torrents resource") { - auto torrent_session = TestSession(); - auto response = std::make_shared(); - auto request = std::make_shared(); - GIVEN("the server is not working properly") { - AND_WHEN("we recive a request") { - tr::session::torrents::del(torrent_session, response, request); - THEN("the server should reply with service unavailable") { - CommonResponse::service_unavailable(response); - } - } - } - GIVEN("the server is working properly") { - torrent_session.valid = true; - WHEN("we recive an invalid request") { - GIVEN("the request doesn't contain valid json") { - request->content << "Not valid"; - THEN("the server should reply with bad request") { - tr::session::torrents::del(torrent_session, response, request); - CommonResponse::bad_request(response); - } - } - GIVEN("it is valid json but are missing requred field") { - request->content << nlohmann::json({{"up_speed", "100"}}); - THEN("the server should reply with bad request") { - tr::session::torrents::del(torrent_session, response, request); - CommonResponse::bad_request(response); - } - } - } - } -} - SCENARIO("We are running a POST /session/torrents resource") { auto torrent_session = TestSession(); auto settings = Config(); @@ -186,3 +152,36 @@ SCENARIO("We are running a POST /session/torrents resource") { } } } + +SCENARIO("We are running a DELETE /session/torrents resource") { + auto torrent_session = TestSession(); + auto response = std::make_shared(); + auto request = std::make_shared(); + GIVEN("the server is not working properly") { + AND_WHEN("we recive a request") { + tr::session::torrents::del(torrent_session, response, request); + THEN("the server should reply with service unavailable") { + CommonResponse::service_unavailable(response); + } + } + } + GIVEN("the server is working properly") { + torrent_session.valid = true; + WHEN("we recive an invalid request") { + GIVEN("the request doesn't contain valid json") { + request->content << "Not valid"; + THEN("the server should reply with bad request") { + tr::session::torrents::del(torrent_session, response, request); + CommonResponse::bad_request(response); + } + } + GIVEN("it is valid json but are missing requred field") { + request->content << nlohmann::json({{"up_speed", "100"}}); + THEN("the server should reply with bad request") { + tr::session::torrents::del(torrent_session, response, request); + CommonResponse::bad_request(response); + } + } + } + } +}