From fddf020444d010a5665912a28a994af0d10e8c75 Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Tue, 9 May 2023 13:21:34 +0100 Subject: [PATCH] fix: failing test 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: https://github.com/torrust/torrust-index-backend/pull/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. --- tests/common/contexts/torrent/responses.rs | 2 +- tests/e2e/contexts/torrent/contract.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/common/contexts/torrent/responses.rs b/tests/common/contexts/torrent/responses.rs index f2b6739c..6f3c5105 100644 --- a/tests/common/contexts/torrent/responses.rs +++ b/tests/common/contexts/torrent/responses.rs @@ -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) } } diff --git a/tests/e2e/contexts/torrent/contract.rs b/tests/e2e/contexts/torrent/contract.rs index 6807ee3a..4ee2bfe3 100644 --- a/tests/e2e/contexts/torrent/contract.rs +++ b/tests/e2e/contexts/torrent/contract.rs @@ -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()); }