1
- use actix_web:: { test, web, App } ;
2
- use anyhow:: Result ;
1
+ use actix_web:: { test, web, App , Result } ;
3
2
use async_trait:: async_trait;
4
3
use atcoder_problems_backend:: server:: {
5
4
config_services, AppData , Authentication , GitHubUserResponse ,
@@ -14,25 +13,30 @@ struct MockAuth;
14
13
15
14
#[ async_trait( ?Send ) ]
16
15
impl Authentication for MockAuth {
17
- async fn get_token ( & self , _: & str ) -> actix_web :: Result < String > {
16
+ async fn get_token ( & self , _: & str ) -> Result < String > {
18
17
unimplemented ! ( )
19
18
}
20
- async fn get_user_id ( & self , _: & str ) -> actix_web :: Result < GitHubUserResponse > {
19
+ async fn get_user_id ( & self , _: & str ) -> Result < GitHubUserResponse > {
21
20
unimplemented ! ( )
22
21
}
23
22
}
24
23
25
24
#[ actix_web:: test]
26
- async fn test_ac_ranking ( ) -> Result < ( ) > {
27
- let pg_pool = sql_client:: initialize_pool ( utils:: get_sql_url_from_env ( ) ) . await ?;
25
+ async fn test_ac_ranking ( ) {
26
+ let pg_pool = sql_client:: initialize_pool ( utils:: get_sql_url_from_env ( ) )
27
+ . await
28
+ . unwrap ( ) ;
28
29
sql_client:: query ( "TRUNCATE accepted_count" )
29
30
. execute ( & pg_pool)
30
- . await ?;
31
+ . await
32
+ . unwrap ( ) ;
31
33
sql_client:: query (
32
34
r"INSERT INTO accepted_count (user_id, problem_count) VALUES ('u1', 1), ('u2', 2), ('u3', 1)" ,
33
35
)
34
36
. execute ( & pg_pool)
35
- . await ?;
37
+ . await
38
+ . unwrap ( ) ;
39
+
36
40
let app_data = AppData :: new ( pg_pool, MockAuth ) ;
37
41
let mut app = test:: init_service (
38
42
App :: new ( )
@@ -143,6 +147,4 @@ async fn test_ac_ranking() -> Result<()> {
143
147
. to_request ( ) ;
144
148
let response = test:: call_service ( & mut app, request) . await ;
145
149
assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
146
-
147
- Ok ( ( ) )
148
150
}
0 commit comments