|
|
|
@ -156,6 +156,17 @@ SCENARIO("We are running a POST /session/torrents resource") { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void theTorrentExists(TestSession &torrent_session) { |
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
torrent_session.torrents_[0].valid = true; |
|
|
|
|
|
|
|
REQUIRE(torrent_session.get_torrents().size() == 1); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
SCENARIO("We are running a DELETE /session/torrents resource") { |
|
|
|
SCENARIO("We are running a DELETE /session/torrents resource") { |
|
|
|
auto torrent_session = TestSession(); |
|
|
|
auto torrent_session = TestSession(); |
|
|
|
auto response = std::make_shared<TestResponse>(); |
|
|
|
auto response = std::make_shared<TestResponse>(); |
|
|
|
@ -193,17 +204,29 @@ SCENARIO("We are running a DELETE /session/torrents resource") { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
GIVEN("fields are correct") { |
|
|
|
GIVEN("fields are correct") { |
|
|
|
request->content << nlohmann::json({{"info_hash", torrent_id}}); |
|
|
|
|
|
|
|
GIVEN("the torrent exists") { |
|
|
|
GIVEN("the torrent exists") { |
|
|
|
torrent_session.torrents_.emplace_back(); |
|
|
|
theTorrentExists(torrent_session); |
|
|
|
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") { |
|
|
|
THEN("the server should reply no content") { |
|
|
|
|
|
|
|
request->content << nlohmann::json({{"info_hash", torrent_id}}); |
|
|
|
|
|
|
|
tr::session::torrents::del(torrent_session, response, request); |
|
|
|
|
|
|
|
CommonResponse::no_content(response); |
|
|
|
|
|
|
|
REQUIRE(torrent_session.get_torrents().size() == 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
GIVEN("we want to remove files") { |
|
|
|
|
|
|
|
THEN("the should reply with no content") { |
|
|
|
|
|
|
|
request->content << nlohmann::json({{"info_hash", torrent_id}, |
|
|
|
|
|
|
|
{"remove_files", true}}); |
|
|
|
tr::session::torrents::del(torrent_session, response, request); |
|
|
|
tr::session::torrents::del(torrent_session, response, request); |
|
|
|
CommonResponse::no_content(response); |
|
|
|
CommonResponse::no_content(response); |
|
|
|
|
|
|
|
REQUIRE(torrent_session.get_torrents().size() == 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
THEN("we should reply with no content") { |
|
|
|
|
|
|
|
request->content << nlohmann::json({{"info_hash", torrent_id}, |
|
|
|
|
|
|
|
{"remove_files", "true"}}); |
|
|
|
|
|
|
|
tr::session::torrents::del(torrent_session, response, request); |
|
|
|
|
|
|
|
CommonResponse::no_content(response); |
|
|
|
|
|
|
|
REQUIRE(torrent_session.get_torrents().size() == 0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
GIVEN("the torrent doesn't exist") { |
|
|
|
GIVEN("the torrent doesn't exist") { |
|
|
|
|