|
|
|
|
@ -7,7 +7,7 @@
|
|
|
|
|
using namespace std; |
|
|
|
|
|
|
|
|
|
const nlohmann::json torrent = { |
|
|
|
|
{"hash", "12a"}, |
|
|
|
|
{"hash", "12a12a12a12a12a12a12"}, |
|
|
|
|
{"paused", false}, |
|
|
|
|
{"seeding", false}, |
|
|
|
|
{"state", 0}, |
|
|
|
|
@ -37,6 +37,9 @@ SCENARIO("We are running a GET /session/torrents resource") {
|
|
|
|
|
} |
|
|
|
|
GIVEN("we have at least one torrent") { |
|
|
|
|
auto t_torrent = TestTorrent(); |
|
|
|
|
libtorrent::sha1_hash sha; |
|
|
|
|
sha.assign("12a12a12a12a12a12a12"); |
|
|
|
|
t_torrent.hash_ = sha; |
|
|
|
|
torrent_session.get_torrents().emplace_back(t_torrent); |
|
|
|
|
THEN("the server should reply with an array of torrents") { |
|
|
|
|
tr::session::torrents::get(torrent_session, response, request); |
|
|
|
|
@ -182,6 +185,34 @@ SCENARIO("We are running a DELETE /session/torrents resource") {
|
|
|
|
|
CommonResponse::bad_request(response); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
GIVEN("required field is wrong type") { |
|
|
|
|
request->content << nlohmann::json({{"info_hash", 1}}); |
|
|
|
|
THEN("the server should reply with bad request") { |
|
|
|
|
tr::session::torrents::del(torrent_session, response, request); |
|
|
|
|
CommonResponse::bad_request(response); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
GIVEN("fields are correct") { |
|
|
|
|
request->content << nlohmann::json({{"info_hash", torrent_id}}); |
|
|
|
|
GIVEN("the torrent exists") { |
|
|
|
|
torrent_session.torrents_.emplace_back(); |
|
|
|
|
libtorrent::sha1_hash sha1_hash; |
|
|
|
|
std::stringstream ss; |
|
|
|
|
ss << torrent_id; |
|
|
|
|
ss >> sha1_hash; |
|
|
|
|
torrent_session.torrents_[0].hash_ = sha1_hash; |
|
|
|
|
THEN("the server should reply no content") { |
|
|
|
|
tr::session::torrents::del(torrent_session, response, request); |
|
|
|
|
CommonResponse::no_content(response); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
GIVEN("the torrent doesn't exist") { |
|
|
|
|
THEN("the server should reply with bad request") { |
|
|
|
|
tr::session::torrents::del(torrent_session, response, request); |
|
|
|
|
CommonResponse::bad_request(response); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|