|
|
|
|
@ -4,16 +4,6 @@
|
|
|
|
|
#include <SessionContext.hpp> |
|
|
|
|
#include <torrents.hpp> |
|
|
|
|
|
|
|
|
|
using namespace std; |
|
|
|
|
|
|
|
|
|
const nlohmann::json torrent = { |
|
|
|
|
{"hash", "12a12a12a12a12a12a12"}, |
|
|
|
|
{"paused", false}, |
|
|
|
|
{"seeding", false}, |
|
|
|
|
{"state", 0}, |
|
|
|
|
{"priority", 0}, |
|
|
|
|
{"name", "Arch"}}; |
|
|
|
|
|
|
|
|
|
SCENARIO("We are running a GET /session/torrents resource") { |
|
|
|
|
auto torrent_session = TestSession(); |
|
|
|
|
auto response = std::make_shared<TestResponse>(); |
|
|
|
|
@ -36,24 +26,16 @@ 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); |
|
|
|
|
torrent_session.theTorrentExists(); |
|
|
|
|
THEN("the server should reply with an array of torrents") { |
|
|
|
|
tr::session::torrents::get(torrent_session, response, request); |
|
|
|
|
CommonResponse::ok(response, {{"torrents", {torrent}}}); |
|
|
|
|
CommonResponse::ok(response, {{"torrents", {torrent_json}}}); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const std::string torrent_id = "c0b0a90089710812fe8c37385a4cc2978eabf3e8"; |
|
|
|
|
const auto magnet_uri = "magnet:?xt=urn:btih:" + torrent_id + "&dn=Taylor Swift&tr=http://tracker.sout.no"; |
|
|
|
|
const auto torrent_url = "http://sout.no/torrent.torrent"; |
|
|
|
|
|
|
|
|
|
SCENARIO("We are running a POST /session/torrents resource") { |
|
|
|
|
auto torrent_session = TestSession(); |
|
|
|
|
auto settings = Config(); |
|
|
|
|
@ -187,17 +169,6 @@ 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") { |
|
|
|
|
auto torrent_session = TestSession(); |
|
|
|
|
auto response = std::make_shared<TestResponse>(); |
|
|
|
|
@ -236,7 +207,7 @@ SCENARIO("We are running a DELETE /session/torrents resource") {
|
|
|
|
|
} |
|
|
|
|
GIVEN("fields are correct") { |
|
|
|
|
GIVEN("the torrent exists") { |
|
|
|
|
theTorrentExists(torrent_session); |
|
|
|
|
torrent_session.theTorrentExists(); |
|
|
|
|
THEN("the server should reply no content") { |
|
|
|
|
request->content << nlohmann::json({{"info_hash", torrent_id}}); |
|
|
|
|
tr::session::torrents::del(torrent_session, response, request); |
|
|
|
|
|