@@ -6,7 +6,7 @@ use pointercrate_demonlist::{
66 LIST_MODERATOR
77} ;
88use rocket:: http:: Status ;
9- use sqlx:: { pool :: PoolConnection , PgConnection , Pool , Postgres } ;
9+ use sqlx:: { PgConnection , Pool , Postgres } ;
1010
1111mod score;
1212
@@ -262,16 +262,42 @@ async fn test_players_pagination(pool: Pool<Postgres>) {
262262 } ) ) ;
263263
264264 // test subdivision filter
265- let filtered_players : Vec < Player > = client
265+ let subdivision_filtered_players : Vec < Player > = client
266266 . get ( "/api/v1/players?subdivision=ENG" )
267267 . expect_status ( Status :: Ok )
268268 . get_result ( )
269269 . await ;
270270
271- assert_eq ! ( filtered_players . len( ) , 1 , "Subdivision filter did not return the correct number of players" ) ;
271+ assert_eq ! ( subdivision_filtered_players . len( ) , 1 , "Subdivision filter did not return the correct number of players" ) ;
272272
273- assert_eq ! ( filtered_players[ 0 ] . base. id, player3. id) ;
274- assert_eq ! ( filtered_players[ 0 ] . nationality, Some ( Nationality {
273+ assert_eq ! ( subdivision_filtered_players[ 0 ] . base. id, player3. id) ;
274+ assert_eq ! ( subdivision_filtered_players[ 0 ] . nationality, Some ( Nationality {
275+ iso_country_code: "GB" . into( ) ,
276+ nation: "United Kingdom" . into( ) ,
277+ subdivision: Some ( Subdivision {
278+ iso_code: "ENG" . into( ) ,
279+ name: "England" . into( ) ,
280+ } ) ,
281+ } ) ) ;
282+
283+ // test nation filter
284+ let nation_filtered_players: Vec < Player > = client
285+ . get ( "/api/v1/players?nation=GB" )
286+ . expect_status ( Status :: Ok )
287+ . get_result ( )
288+ . await ;
289+
290+ assert_eq ! ( nation_filtered_players. len( ) , 2 , "Nation filter did not return the correct number of players" ) ;
291+
292+ assert_eq ! ( nation_filtered_players[ 0 ] . base. id, player2. id) ;
293+ assert_eq ! ( nation_filtered_players[ 1 ] . base. id, player3. id) ;
294+
295+ assert_eq ! ( nation_filtered_players[ 0 ] . nationality, Some ( Nationality {
296+ iso_country_code: "GB" . into( ) ,
297+ nation: "United Kingdom" . into( ) ,
298+ subdivision: None ,
299+ } ) ) ;
300+ assert_eq ! ( nation_filtered_players[ 1 ] . nationality, Some ( Nationality {
275301 iso_country_code: "GB" . into( ) ,
276302 nation: "United Kingdom" . into( ) ,
277303 subdivision: Some ( Subdivision {
0 commit comments