|
|
|
@ -48,12 +48,16 @@ SCENARIO("We are running a PATCH /session/torrents/id resource") { |
|
|
|
CommonResponse::service_unavailable(response); |
|
|
|
CommonResponse::service_unavailable(response); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
auto torrent = TestTorrent(); |
|
|
|
|
|
|
|
torrent_session.valid = true; |
|
|
|
torrent_session.valid = true; |
|
|
|
GIVEN("we have the server is working properly and we recive a request") { |
|
|
|
GIVEN("we have the server is working properly and we recive a request") { |
|
|
|
WHEN("the request path is a proper id") { |
|
|
|
WHEN("the request path is a proper id") { |
|
|
|
request->path = "/session/torrents/" + torrent_id; |
|
|
|
request->path = "/session/torrents/" + torrent_id; |
|
|
|
GIVEN("we have the torrent") { |
|
|
|
GIVEN("the request is valid and we have the torrent") { |
|
|
|
|
|
|
|
request->content << nlohmann::json({ |
|
|
|
|
|
|
|
{"paused", "true"}, |
|
|
|
|
|
|
|
{"up_limit", "109"}, |
|
|
|
|
|
|
|
{"down_limit", 100}, |
|
|
|
|
|
|
|
}); |
|
|
|
torrent_session.theTorrentExists(); |
|
|
|
torrent_session.theTorrentExists(); |
|
|
|
WHEN("The torrent isn't valid") { |
|
|
|
WHEN("The torrent isn't valid") { |
|
|
|
torrent_session.torrents_.back().valid = false; |
|
|
|
torrent_session.torrents_.back().valid = false; |
|
|
|
@ -62,6 +66,23 @@ SCENARIO("We are running a PATCH /session/torrents/id resource") { |
|
|
|
CommonResponse::bad_request(response); |
|
|
|
CommonResponse::bad_request(response); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
THEN("the server should reply with accepted") { |
|
|
|
|
|
|
|
tr::session::torrents::id::patch(torrent_session, response, request); |
|
|
|
|
|
|
|
CommonResponse::accepted(response); |
|
|
|
|
|
|
|
REQUIRE(torrent_session.get_torrents().back().status().paused); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
THEN("the request is valid json, but doesn't have any of the required fields") { |
|
|
|
|
|
|
|
request->content << "{}"; |
|
|
|
|
|
|
|
THEN("the server should reply with bad request") { |
|
|
|
|
|
|
|
tr::session::torrents::id::patch(torrent_session, response, request); |
|
|
|
|
|
|
|
CommonResponse::bad_request(response); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
request->content << "Not valid"; |
|
|
|
|
|
|
|
THEN("the server should reply with bad request") { |
|
|
|
|
|
|
|
tr::session::torrents::id::patch(torrent_session, response, request); |
|
|
|
|
|
|
|
CommonResponse::bad_request(response); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|