|
|
|
|
@ -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<TestResponse>(); |
|
|
|
|
auto request = std::make_shared<TestRequest>(); |
|
|
|
|
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<TestResponse>(); |
|
|
|
|
auto request = std::make_shared<TestRequest>(); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|