|
|
|
@ -5,6 +5,15 @@ |
|
|
|
|
|
|
|
|
|
|
|
using namespace std; |
|
|
|
using namespace std; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const nlohmann::json torrent = { |
|
|
|
|
|
|
|
{"hash", "12a"}, |
|
|
|
|
|
|
|
{"paused", false}, |
|
|
|
|
|
|
|
{"seeding", false}, |
|
|
|
|
|
|
|
{"state", 0}, |
|
|
|
|
|
|
|
{"priority", 0}, |
|
|
|
|
|
|
|
{"name", "Arch"} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
SCENARIO("We are running a GET /session/torrents resource") { |
|
|
|
SCENARIO("We are running a GET /session/torrents resource") { |
|
|
|
auto torrent_session = TestSession(); |
|
|
|
auto torrent_session = TestSession(); |
|
|
|
auto response = std::make_shared<TestResponse>(); |
|
|
|
auto response = std::make_shared<TestResponse>(); |
|
|
|
@ -19,12 +28,22 @@ SCENARIO("We are running a GET /session/torrents resource") { |
|
|
|
} |
|
|
|
} |
|
|
|
GIVEN("the server is working properly") { |
|
|
|
GIVEN("the server is working properly") { |
|
|
|
torrent_session.valid = true; |
|
|
|
torrent_session.valid = true; |
|
|
|
AND_WHEN("the session the session has no torrents") { |
|
|
|
WHEN("we recive a valid request") { |
|
|
|
tr::session::torrents::get(torrent_session, response, request); |
|
|
|
GIVEN("we have no torrents") { |
|
|
|
THEN("the server should reply with an empty array") { |
|
|
|
THEN("the server should reply with an empty array") { |
|
|
|
CommonResponse::ok(response, {{"torrents", nlohmann::json::array()}}); |
|
|
|
tr::session::torrents::get(torrent_session,response,request); |
|
|
|
|
|
|
|
CommonResponse::ok(response, {{"torrents", nlohmann::json::array()}}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
GIVEN("we have at least one torrent"){ |
|
|
|
|
|
|
|
auto t_torrent=TestTorrent(); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
CommonResponse::ok(response, {{"torrents", {torrent}}}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |