File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
packages/tracker-core/src/torrent Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -297,4 +297,44 @@ mod tests {
297297 ) ;
298298 }
299299 }
300+
301+ mod getting_basic_torrent_info_for_multiple_torrents_at_once {
302+
303+ use std:: sync:: Arc ;
304+
305+ use crate :: core_tests:: sample_info_hash;
306+ use crate :: torrent:: repository:: in_memory:: InMemoryTorrentRepository ;
307+ use crate :: torrent:: services:: tests:: sample_peer;
308+ use crate :: torrent:: services:: { get_torrents, BasicInfo } ;
309+
310+ #[ tokio:: test]
311+ async fn it_should_return_an_empty_list_if_none_of_the_requested_torrents_is_found ( ) {
312+ let in_memory_torrent_repository = Arc :: new ( InMemoryTorrentRepository :: default ( ) ) ;
313+
314+ let torrent_info = get_torrents ( & in_memory_torrent_repository, & [ sample_info_hash ( ) ] ) ;
315+
316+ assert ! ( torrent_info. is_empty( ) ) ;
317+ }
318+
319+ #[ tokio:: test]
320+ async fn it_should_return_a_list_with_basic_info_about_the_requested_torrents ( ) {
321+ let in_memory_torrent_repository = Arc :: new ( InMemoryTorrentRepository :: default ( ) ) ;
322+
323+ let info_hash = sample_info_hash ( ) ;
324+
325+ let ( ) = in_memory_torrent_repository. upsert_peer ( & info_hash, & sample_peer ( ) ) ;
326+
327+ let torrent_info = get_torrents ( & in_memory_torrent_repository, & [ info_hash] ) ;
328+
329+ assert_eq ! (
330+ torrent_info,
331+ vec!( BasicInfo {
332+ info_hash,
333+ seeders: 1 ,
334+ completed: 0 ,
335+ leechers: 0 ,
336+ } )
337+ ) ;
338+ }
339+ }
300340}
You can’t perform that action at this time.
0 commit comments