@@ -3,15 +3,15 @@ use crate::tests::builders::CrateBuilder;
33use crate :: tests:: util:: { RequestHelper , TestApp } ;
44use crates_io_database:: schema:: { crate_owners, users} ;
55use diesel:: prelude:: * ;
6+ use diesel_async:: RunQueryDsl ;
67use http:: StatusCode ;
78use insta:: assert_snapshot;
89
910/// See <https://github.com/rust-lang/crates.io/issues/2736>.
1011#[ tokio:: test( flavor = "multi_thread" ) ]
1112async fn test_issue_2736 ( ) -> anyhow:: Result < ( ) > {
1213 let ( app, _) = TestApp :: full ( ) . empty ( ) . await ;
13- let mut conn = app. db_conn ( ) ;
14- let mut async_conn = app. async_db_conn ( ) . await ;
14+ let mut conn = app. db_conn ( ) . await ;
1515
1616 // - A user had a GitHub account named, let's say, `foo`
1717 let foo1 = app. db_new_user ( "foo" ) . await ;
@@ -20,7 +20,7 @@ async fn test_issue_2736() -> anyhow::Result<()> {
2020 let someone_else = app. db_new_user ( "someone_else" ) . await ;
2121
2222 let krate = CrateBuilder :: new ( "crate1" , someone_else. as_model ( ) . id )
23- . expect_build ( & mut async_conn )
23+ . expect_build ( & mut conn )
2424 . await ;
2525
2626 diesel:: insert_into ( crate_owners:: table)
@@ -31,7 +31,8 @@ async fn test_issue_2736() -> anyhow::Result<()> {
3131 owner_kind : OwnerKind :: User ,
3232 email_notifications : true ,
3333 } )
34- . execute ( & mut conn) ?;
34+ . execute ( & mut conn)
35+ . await ?;
3536
3637 // - `foo` deleted their GitHub account (but crates.io has no real knowledge of this)
3738 // - `foo` recreated their GitHub account with the same username (because it was still available), but in this situation GitHub assigns them a new ID
@@ -41,13 +42,14 @@ async fn test_issue_2736() -> anyhow::Result<()> {
4142 let github_ids = users:: table
4243 . filter ( users:: gh_login. eq ( "foo" ) )
4344 . select ( users:: gh_id)
44- . load :: < i32 > ( & mut conn) ?;
45+ . load :: < i32 > ( & mut conn)
46+ . await ?;
4547
4648 assert_eq ! ( github_ids. len( ) , 2 ) ;
4749 assert_ne ! ( github_ids[ 0 ] , github_ids[ 1 ] ) ;
4850
4951 // - The new `foo` account is NOT an owner of the crate
50- let owners = krate. owners ( & mut conn) ?;
52+ let owners = krate. async_owners ( & mut conn) . await ?;
5153 assert_eq ! ( owners. len( ) , 2 ) ;
5254 assert_none ! ( owners. iter( ) . find( |o| o. id( ) == foo2. as_model( ) . id) ) ;
5355
@@ -56,7 +58,7 @@ async fn test_issue_2736() -> anyhow::Result<()> {
5658 assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
5759 assert_snapshot ! ( response. text( ) , @r#"{"msg":"owners successfully removed","ok":true}"# ) ;
5860
59- let owners = krate. owners ( & mut conn) ?;
61+ let owners = krate. async_owners ( & mut conn) . await ?;
6062 assert_eq ! ( owners. len( ) , 1 ) ;
6163 assert_eq ! ( owners[ 0 ] . id( ) , someone_else. as_model( ) . id) ;
6264
0 commit comments