Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul Packages Testing: Add tests for http-tracker-core package #1349

Open
josecelano opened this issue Mar 3, 2025 · 0 comments
Open
Labels
- Developer - Torrust Improvement Experience Easy Good for Newcomers good first issue Good for newcomers Testing Checking Torrust

Comments

@josecelano
Copy link
Member

josecelano commented Mar 3, 2025

Add tests for http-tracker-core package.

Initial Code Coverage

cargo llvm-cov --package bittorrent-http-tracker-core

Filtered lines for the package:

Filename                                                                    Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
packages/http-tracker-core/src/lib.rs                                             1                 0   100.00%           1                 0   100.00%           5                 0   100.00%           0                 0         -
packages/http-tracker-core/src/services/announce.rs                              87                17    80.46%          37                 5    86.49%         442                32    92.76%           0                 0         -
packages/http-tracker-core/src/services/scrape.rs                                78                10    87.18%          35                 5    85.71%         611                26    95.74%           0                 0         -
packages/http-tracker-core/src/statistics/event/handler.rs                       53                 1    98.11%          18                 0   100.00%         133                 0   100.00%           0                 0         -
packages/http-tracker-core/src/statistics/event/listener.rs                       6                 6     0.00%           2                 2     0.00%           5                 5     0.00%           0                 0         -
packages/http-tracker-core/src/statistics/event/sender.rs                         5                 1    80.00%           3                 1    66.67%           5                 1    80.00%           0                 0         -
packages/http-tracker-core/src/statistics/keeper.rs                              17                 4    76.47%           9                 3    66.67%          51                11    78.43%           0                 0         -
packages/http-tracker-core/src/statistics/repository.rs                          35                 1    97.14%          16                 1    93.75%          48                 3    93.75%           0                 0         -
packages/http-tracker-core/src/statistics/services.rs                            11                 0   100.00%           5                 0   100.00%          57                 0   100.00%           0                 0         -
packages/http-tracker-core/src/statistics/setup.rs                                8                 0   100.00%           5                 0   100.00%          41                 0   100.00%           0                 0         -

Full report:

Filename                                                                    Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
contrib/bencode/src/access/bencode.rs                                             8                 8     0.00%           8                 8     0.00%          24                24     0.00%           0                 0         -
contrib/bencode/src/access/convert.rs                                            39                39     0.00%          15                15     0.00%         154               154     0.00%           0                 0         -
contrib/bencode/src/access/dict.rs                                               10                10     0.00%          10                10     0.00%          30                30     0.00%           0                 0         -
contrib/bencode/src/access/list.rs                                               18                18     0.00%          12                12     0.00%          43                43     0.00%           0                 0         -
contrib/bencode/src/cow.rs                                                        4                 4     0.00%           4                 4     0.00%          12                12     0.00%           0                 0         -
contrib/bencode/src/mutable/bencode_mut.rs                                       48                48     0.00%          15                15     0.00%          70                70     0.00%           0                 0         -
contrib/bencode/src/mutable/encode.rs                                            20                20     0.00%           6                 6     0.00%          54                54     0.00%           0                 0         -
contrib/bencode/src/reference/bencode_ref.rs                                     46                46     0.00%          11                11     0.00%          56                56     0.00%           0                 0         -
contrib/bencode/src/reference/decode.rs                                          99                99     0.00%           8                 8     0.00%         107               107     0.00%           0                 0         -
contrib/bencode/src/reference/decode_opt.rs                                       5                 5     0.00%           5                 5     0.00%          19                19     0.00%           0                 0         -
packages/clock/src/clock/mod.rs                                                   2                 2     0.00%           2                 2     0.00%           6                 6     0.00%           0                 0         -
packages/clock/src/clock/stopped/mod.rs                                          31                31     0.00%          15                15     0.00%          59                59     0.00%           0                 0         -
packages/clock/src/clock/working/mod.rs                                           2                 1    50.00%           2                 1    50.00%           6                 3    50.00%           0                 0         -
packages/clock/src/conv/mod.rs                                                    3                 3     0.00%           3                 3     0.00%          13                13     0.00%           0                 0         -
packages/configuration/src/lib.rs                                                30                18    40.00%          19                 7    63.16%          90                41    54.44%           0                 0         -
packages/configuration/src/logging.rs                                            32                32     0.00%           5                 5     0.00%          45                45     0.00%           0                 0         -
packages/configuration/src/v2_0_0/core.rs                                        20                 8    60.00%          13                 3    76.92%          57                16    71.93%           0                 0         -
packages/configuration/src/v2_0_0/database.rs                                     7                 4    42.86%           4                 1    75.00%          23                11    52.17%           0                 0         -
packages/configuration/src/v2_0_0/health_check_api.rs                             2                 0   100.00%           2                 0   100.00%           8                 0   100.00%           0                 0         -
packages/configuration/src/v2_0_0/http_tracker.rs                                 3                 3     0.00%           3                 3     0.00%          12                12     0.00%           0                 0         -
packages/configuration/src/v2_0_0/logging.rs                                      2                 0   100.00%           2                 0   100.00%           8                 0   100.00%           0                 0         -
packages/configuration/src/v2_0_0/mod.rs                                         42                42     0.00%          11                11     0.00%          59                59     0.00%           0                 0         -
packages/configuration/src/v2_0_0/network.rs                                      3                 0   100.00%           3                 0   100.00%          12                 0   100.00%           0                 0         -
packages/configuration/src/v2_0_0/tracker_api.rs                                 10                 5    50.00%           6                 1    83.33%          24                 5    79.17%           0                 0         -
packages/configuration/src/v2_0_0/udp_tracker.rs                                  3                 3     0.00%           3                 3     0.00%          12                12     0.00%           0                 0         -
packages/http-protocol/src/percent_encoding.rs                                    4                 4     0.00%           2                 2     0.00%           8                 8     0.00%           0                 0         -
packages/http-protocol/src/v1/query.rs                                           41                41     0.00%          14                14     0.00%          85                85     0.00%           0                 0         -
packages/http-protocol/src/v1/requests/announce.rs                              118               109     7.63%          25                22    12.00%         180               161    10.56%           0                 0         -
packages/http-protocol/src/v1/requests/scrape.rs                                 17                17     0.00%           4                 4     0.00%          29                29     0.00%           0                 0         -
packages/http-protocol/src/v1/responses/announce.rs                              32                32     0.00%          11                11     0.00%         104               104     0.00%           0                 0         -
packages/http-protocol/src/v1/responses/error.rs                                  7                 7     0.00%           7                 7     0.00%          33                33     0.00%           0                 0         -
packages/http-protocol/src/v1/responses/scrape.rs                                 6                 6     0.00%           2                 2     0.00%          22                22     0.00%           0                 0         -
packages/http-protocol/src/v1/services/peer_ip_resolver.rs                       16                 8    50.00%           3                 1    66.67%          19                11    42.11%           0                 0         -
packages/http-tracker-core/src/container.rs                                       2                 2     0.00%           2                 2     0.00%          42                42     0.00%           0                 0         -
packages/http-tracker-core/src/lib.rs                                             1                 0   100.00%           1                 0   100.00%           5                 0   100.00%           0                 0         -
packages/http-tracker-core/src/services/announce.rs                              87                17    80.46%          37                 5    86.49%         442                32    92.76%           0                 0         -
packages/http-tracker-core/src/services/scrape.rs                                78                10    87.18%          35                 5    85.71%         611                26    95.74%           0                 0         -
packages/http-tracker-core/src/statistics/event/handler.rs                       53                 1    98.11%          18                 0   100.00%         133                 0   100.00%           0                 0         -
packages/http-tracker-core/src/statistics/event/listener.rs                       6                 6     0.00%           2                 2     0.00%           5                 5     0.00%           0                 0         -
packages/http-tracker-core/src/statistics/event/sender.rs                         5                 1    80.00%           3                 1    66.67%           5                 1    80.00%           0                 0         -
packages/http-tracker-core/src/statistics/keeper.rs                              17                 4    76.47%           9                 3    66.67%          51                11    78.43%           0                 0         -
packages/http-tracker-core/src/statistics/repository.rs                          35                 1    97.14%          16                 1    93.75%          48                 3    93.75%           0                 0         -
packages/http-tracker-core/src/statistics/services.rs                            11                 0   100.00%           5                 0   100.00%          57                 0   100.00%           0                 0         -
packages/http-tracker-core/src/statistics/setup.rs                                8                 0   100.00%           5                 0   100.00%          41                 0   100.00%           0                 0         -
packages/located-error/src/lib.rs                                                 7                 7     0.00%           5                 5     0.00%          26                26     0.00%           0                 0         -
packages/primitives/src/core.rs                                                   8                 1    87.50%           4                 1    75.00%          17                 3    82.35%           0                 0         -
packages/primitives/src/pagination.rs                                            13                13     0.00%           4                 4     0.00%          21                21     0.00%           0                 0         -
packages/primitives/src/peer.rs                                                  72                65     9.72%          42                37    11.90%         211               196     7.11%           0                 0         -
packages/primitives/src/swarm_metadata.rs                                         1                 0   100.00%           1                 0   100.00%           3                 0   100.00%           0                 0         -
packages/primitives/src/torrent_metrics.rs                                        1                 1     0.00%           1                 1     0.00%           6                 6     0.00%           0                 0         -
packages/test-helpers/src/configuration.rs                                       24                20    16.67%          11                 7    36.36%         124                60    51.61%           0                 0         -
packages/test-helpers/src/logging.rs                                             52                52     0.00%          18                18     0.00%          82                82     0.00%           0                 0         -
packages/test-helpers/src/random.rs                                               1                 0   100.00%           1                 0   100.00%           3                 0   100.00%           0                 0         -
packages/torrent-repository/src/entry/mutex_parking_lot.rs                        9                 9     0.00%           9                 9     0.00%          27                27     0.00%           0                 0         -
packages/torrent-repository/src/entry/mutex_std.rs                                9                 6    33.33%           9                 6    33.33%          29                20    31.03%           0                 0         -
packages/torrent-repository/src/entry/mutex_tokio.rs                             25                25     0.00%          17                17     0.00%          35                35     0.00%           0                 0         -
packages/torrent-repository/src/entry/peer_list.rs                               23                13    43.48%          13                 7    46.15%          53                27    49.06%           0                 0         -
packages/torrent-repository/src/entry/rw_lock_parking_lot.rs                      9                 9     0.00%           9                 9     0.00%          27                27     0.00%           0                 0         -
packages/torrent-repository/src/entry/single.rs                                  23                18    21.74%           9                 6    33.33%          54                33    38.89%           0                 0         -
packages/torrent-repository/src/repository/dash_map_mutex_std.rs                 47                47     0.00%          15                15     0.00%          75                75     0.00%           0                 0         -
packages/torrent-repository/src/repository/rw_lock_std.rs                        37                37     0.00%          16                16     0.00%          88                88     0.00%           0                 0         -
packages/torrent-repository/src/repository/rw_lock_std_mutex_std.rs              40                40     0.00%          14                14     0.00%          89                89     0.00%           0                 0         -
packages/torrent-repository/src/repository/rw_lock_std_mutex_tokio.rs            66                66     0.00%          25                25     0.00%         125               125     0.00%           0                 0         -
packages/torrent-repository/src/repository/rw_lock_tokio.rs                      72                72     0.00%          27                27     0.00%         100               100     0.00%           0                 0         -
packages/torrent-repository/src/repository/rw_lock_tokio_mutex_std.rs            79                79     0.00%          26                26     0.00%          99                99     0.00%           0                 0         -
packages/torrent-repository/src/repository/rw_lock_tokio_mutex_tokio.rs          89                89     0.00%          24                24     0.00%         104               104     0.00%           0                 0         -
packages/torrent-repository/src/repository/skip_map_mutex_std.rs                126               119     5.56%          42                38     9.52%         228               214     6.14%           0                 0         -
packages/tracker-core/src/announce_handler.rs                                    39                15    61.54%          11                 3    72.73%          94                31    67.02%           0                 0         -
packages/tracker-core/src/authentication/handler.rs                              64                64     0.00%          17                17     0.00%          97                97     0.00%           0                 0         -
packages/tracker-core/src/authentication/key/mod.rs                              17                17     0.00%           3                 3     0.00%          31                31     0.00%           0                 0         -
packages/tracker-core/src/authentication/key/peer_key.rs                         28                28     0.00%          10                10     0.00%          51                51     0.00%           0                 0         -
packages/tracker-core/src/authentication/key/repository/in_memory.rs             23                23     0.00%          10                10     0.00%          25                25     0.00%           0                 0         -
packages/tracker-core/src/authentication/key/repository/persisted.rs             15                15     0.00%           4                 4     0.00%          17                17     0.00%           0                 0         -
packages/tracker-core/src/authentication/service.rs                              16                15     6.25%           6                 5    16.67%          31                25    19.35%           0                 0         -
packages/tracker-core/src/container.rs                                            1                 1     0.00%           1                 1     0.00%          45                45     0.00%           0                 0         -
packages/tracker-core/src/databases/driver/mod.rs                                 9                 3    66.67%           1                 0   100.00%           8                 1    87.50%           0                 0         -
packages/tracker-core/src/databases/driver/mysql.rs                             161               161     0.00%          31                31     0.00%         190               190     0.00%           0                 0         -
packages/tracker-core/src/databases/driver/sqlite.rs                            217               202     6.91%          33                31     6.06%         208               174    16.35%           0                 0         -
packages/tracker-core/src/databases/error.rs                                      7                 7     0.00%           4                 4     0.00%          31                31     0.00%           0                 0         -
packages/tracker-core/src/databases/mod.rs                                        5                 5     0.00%           2                 2     0.00%           4                 4     0.00%           0                 0         -
packages/tracker-core/src/databases/setup.rs                                      6                 1    83.33%           1                 0   100.00%           6                 1    83.33%           0                 0         -
packages/tracker-core/src/error.rs                                                4                 4     0.00%           4                 4     0.00%          12                12     0.00%           0                 0         -
packages/tracker-core/src/scrape_handler.rs                                      11                 1    90.91%           3                 0   100.00%          19                 1    94.74%           0                 0         -
packages/tracker-core/src/torrent/manager.rs                                     11                11     0.00%           3                 3     0.00%          28                28     0.00%           0                 0         -
packages/tracker-core/src/torrent/repository/in_memory.rs                        19                10    47.37%          10                 6    40.00%          36                21    41.67%           0                 0         -
packages/tracker-core/src/torrent/repository/persisted.rs                         3                 2    33.33%           3                 2    33.33%          11                 6    45.45%           0                 0         -
packages/tracker-core/src/torrent/services.rs                                    23                23     0.00%           5                 5     0.00%          49                49     0.00%           0                 0         -
packages/tracker-core/src/whitelist/authorization.rs                              5                 3    40.00%           4                 2    50.00%          13                 4    69.23%           0                 0         -
packages/tracker-core/src/whitelist/manager.rs                                   25                25     0.00%           7                 7     0.00%          26                26     0.00%           0                 0         -
packages/tracker-core/src/whitelist/repository/in_memory.rs                      14                14     0.00%           8                 8     0.00%          17                17     0.00%           0                 0         -
packages/tracker-core/src/whitelist/repository/persisted.rs                      22                22     0.00%           4                 4     0.00%          24                24     0.00%           0                 0         -
packages/tracker-core/src/whitelist/setup.rs                                      1                 1     0.00%           1                 1     0.00%           7                 7     0.00%           0                 0         -
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                          2612              2176    16.69%         916               706    22.93%        5629              3799    32.51%           0                 0         -
@josecelano josecelano added - Developer - Torrust Improvement Experience Testing Checking Torrust Easy Good for Newcomers good first issue Good for newcomers labels Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Developer - Torrust Improvement Experience Easy Good for Newcomers good first issue Good for newcomers Testing Checking Torrust
Projects
None yet
Development

No branches or pull requests

1 participant