Skip to content

Commit

Permalink
fix: failing test
Browse files Browse the repository at this point in the history
The test for listing torrents was failing becuase the uploaded torrents
was not in the result. Since we added a pagination limit in this PR:

#142

Now it can happen that the torrent you've just uploaded is not in the
response, because tests run in paralell.

When we will able to run this test mocking the `TrackerService` we
couuld run it with an isolated environment, so the expected result if
always only one torrent. Then we could check that the torrent is on the
list again.
  • Loading branch information
josecelano committed May 9, 2023
1 parent 6cc1380 commit fddf020
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/common/contexts/torrent/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct TorrentList {
}

impl TorrentList {
pub fn contains(&self, torrent_id: Id) -> bool {
pub fn _contains(&self, torrent_id: Id) -> bool {
self.results.iter().any(|item| item.torrent_id == torrent_id)
}
}
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/contexts/torrent/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ mod for_guests {
let client = Client::unauthenticated(&env.server_socket_addr().unwrap());

let uploader = new_logged_in_user(&env).await;
let (_test_torrent, indexed_torrent) = upload_random_torrent_to_index(&uploader, &env).await;
let (_test_torrent, _indexed_torrent) = upload_random_torrent_to_index(&uploader, &env).await;

let response = client.get_torrents(Query::empty()).await;

let torrent_list_response: TorrentListResponse = serde_json::from_str(&response.body).unwrap();

assert!(torrent_list_response.data.total > 0);
assert!(torrent_list_response.data.contains(indexed_torrent.torrent_id));
assert!(response.is_json_and_ok());
}

Expand Down

0 comments on commit fddf020

Please sign in to comment.