|
|
|
|
@ -51,13 +51,14 @@ SCENARIO("We are running a GET /session/torrents resource") {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
auto response = std::make_shared<TestResponse>(); |
|
|
|
|
auto request = std::make_shared<TestRequest>(); |
|
|
|
|
const auto magnet_uri = "magnet:?xt=urn:btih:" + torrent_id + "&dn=Taylor Swift&tr=http://tracker.sout.no"; |
|
|
|
|
GIVEN("the server is not working properly") { |
|
|
|
|
AND_WHEN("we recive a request") { |
|
|
|
|
tr::session::torrents::post(settings, torrent_session, response, request); |
|
|
|
|
@ -70,13 +71,24 @@ SCENARIO("We are running a POST /session/torrents resource") {
|
|
|
|
|
torrent_session.valid = true; |
|
|
|
|
WHEN("we recive a valid request") { |
|
|
|
|
GIVEN("we use the default download directory") { |
|
|
|
|
request->content << nlohmann::json::object({{"magnet_uri", magnet_uri}}); |
|
|
|
|
THEN("the server should reply with created") { |
|
|
|
|
tr::session::torrents::post(settings, torrent_session, response, request); |
|
|
|
|
CommonResponse::created(response, request, "/session/torrents/" + torrent_id); |
|
|
|
|
REQUIRE(torrent_session.get_torrents().size() == 1); |
|
|
|
|
REQUIRE((torrent_session.get_torrents()[0]).status().save_path == "/toREST"); |
|
|
|
|
AND_WHEN("we fill the magnet uri field"){ |
|
|
|
|
THEN("the server should reply with created") { |
|
|
|
|
request->content << nlohmann::json::object({{"magnet_uri", magnet_uri}}); |
|
|
|
|
tr::session::torrents::post(settings, torrent_session, response, request); |
|
|
|
|
CommonResponse::created(response, request, "/session/torrents/" + torrent_id); |
|
|
|
|
REQUIRE(torrent_session.get_torrents().size() == 1); |
|
|
|
|
REQUIRE((torrent_session.get_torrents()[0]).status().save_path == "/toREST"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// AND_WHEN("we fill the magnet url field"){
|
|
|
|
|
// THEN("the server should reply with created") {
|
|
|
|
|
// request->content << nlohmann::json::object({{"url", torrent_url}});
|
|
|
|
|
// tr::session::torrents::post(settings, torrent_session, response, request);
|
|
|
|
|
// CommonResponse::created(response, request, "/session/torrents/" + std::string("0000000000000000000000000000000000000000"));
|
|
|
|
|
// REQUIRE(torrent_session.get_torrents().size() == 1);
|
|
|
|
|
// REQUIRE((torrent_session.get_torrents()[0]).status().save_path == "/toREST");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
GIVEN("we specify a absolute save path") { |
|
|
|
|
request->content << nlohmann::json::object( |
|
|
|
|
|