@@ -14,9 +14,9 @@ pub struct PairingStore {
1414}
1515
1616impl PairingStore {
17- pub fn new ( db_path : & Path ) -> Self {
17+ pub fn new ( db_path : & Path ) -> anyhow :: Result < Self > {
1818 if let Some ( parent) = db_path. parent ( ) {
19- std:: fs:: create_dir_all ( parent) . expect ( "Failed to create pairing database directory" ) ;
19+ std:: fs:: create_dir_all ( parent) ? ;
2020 }
2121
2222 let options = SqliteConnectOptions :: new ( )
@@ -27,11 +27,11 @@ impl PairingStore {
2727
2828 let pool = SqlitePoolOptions :: new ( ) . connect_lazy_with ( options) ;
2929
30- Self {
30+ Ok ( Self {
3131 pairings : RwLock :: new ( HashMap :: new ( ) ) ,
3232 pool,
3333 initialized : OnceCell :: new ( ) ,
34- }
34+ } )
3535 }
3636
3737 async fn ensure_initialized ( & self ) -> anyhow:: Result < & Pool < Sqlite > > {
@@ -343,7 +343,7 @@ mod tests {
343343 #[ tokio:: test]
344344 async fn test_pairing_lifecycle ( ) {
345345 let tmp = TempDir :: new ( ) . unwrap ( ) ;
346- let store = PairingStore :: new ( & tmp. path ( ) . join ( "test.db" ) ) ;
346+ let store = PairingStore :: new ( & tmp. path ( ) . join ( "test.db" ) ) . unwrap ( ) ;
347347 let user = test_user ( "telegram" , "12345" ) ;
348348
349349 let state = store. get ( & user) . await . unwrap ( ) ;
@@ -381,7 +381,7 @@ mod tests {
381381 #[ tokio:: test]
382382 async fn test_pending_code_flow ( ) {
383383 let tmp = TempDir :: new ( ) . unwrap ( ) ;
384- let store = PairingStore :: new ( & tmp. path ( ) . join ( "test.db" ) ) ;
384+ let store = PairingStore :: new ( & tmp. path ( ) . join ( "test.db" ) ) . unwrap ( ) ;
385385
386386 let expires = chrono:: Utc :: now ( ) . timestamp ( ) + 300 ;
387387 store
@@ -399,7 +399,7 @@ mod tests {
399399 #[ tokio:: test]
400400 async fn test_expired_code ( ) {
401401 let tmp = TempDir :: new ( ) . unwrap ( ) ;
402- let store = PairingStore :: new ( & tmp. path ( ) . join ( "test.db" ) ) ;
402+ let store = PairingStore :: new ( & tmp. path ( ) . join ( "test.db" ) ) . unwrap ( ) ;
403403
404404 let expired = chrono:: Utc :: now ( ) . timestamp ( ) - 10 ;
405405 store
@@ -427,7 +427,7 @@ mod tests {
427427 let user = test_user ( "discord" , "user42" ) ;
428428
429429 {
430- let store = PairingStore :: new ( & db_path) ;
430+ let store = PairingStore :: new ( & db_path) . unwrap ( ) ;
431431 store
432432 . set (
433433 & user,
@@ -440,7 +440,7 @@ mod tests {
440440 . unwrap ( ) ;
441441 }
442442
443- let store2 = PairingStore :: new ( & db_path) ;
443+ let store2 = PairingStore :: new ( & db_path) . unwrap ( ) ;
444444 let state = store2. get ( & user) . await . unwrap ( ) ;
445445 match state {
446446 PairingState :: Paired { session_id, .. } => assert_eq ! ( session_id, "s-42" ) ,
@@ -451,7 +451,7 @@ mod tests {
451451 #[ tokio:: test]
452452 async fn test_remove_all_for_platform ( ) {
453453 let tmp = TempDir :: new ( ) . unwrap ( ) ;
454- let store = PairingStore :: new ( & tmp. path ( ) . join ( "test.db" ) ) ;
454+ let store = PairingStore :: new ( & tmp. path ( ) . join ( "test.db" ) ) . unwrap ( ) ;
455455
456456 let tg1 = test_user ( "telegram" , "111" ) ;
457457 let tg2 = test_user ( "telegram" , "222" ) ;
0 commit comments