File tree Expand file tree Collapse file tree 3 files changed +34
-4
lines changed Expand file tree Collapse file tree 3 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -31,3 +31,14 @@ pub struct ReverseLookupNew {
31
31
pub sk_id : String ,
32
32
pub source : String ,
33
33
}
34
+
35
+ impl From < ReverseLookupNew > for ReverseLookup {
36
+ fn from ( new : ReverseLookupNew ) -> Self {
37
+ Self {
38
+ lookup_id : new. lookup_id ,
39
+ sk_id : new. sk_id ,
40
+ pk_id : new. pk_id ,
41
+ source : new. source ,
42
+ }
43
+ }
44
+ }
Original file line number Diff line number Diff line change @@ -48,14 +48,31 @@ impl ReverseLookupInterface for Store {
48
48
impl ReverseLookupInterface for MockDb {
49
49
async fn insert_reverse_lookup (
50
50
& self ,
51
- _new : ReverseLookupNew ,
51
+ new : ReverseLookupNew ,
52
52
) -> CustomResult < ReverseLookup , errors:: StorageError > {
53
- Err ( errors:: StorageError :: MockDbError . into ( ) )
53
+ let reverse_lookup_insert = ReverseLookup :: from ( new) ;
54
+ self . reverse_lookups
55
+ . lock ( )
56
+ . await
57
+ . push ( reverse_lookup_insert. clone ( ) ) ;
58
+ Ok ( reverse_lookup_insert)
54
59
}
55
60
async fn get_lookup_by_lookup_id (
56
61
& self ,
57
- _id : & str ,
62
+ lookup_id : & str ,
58
63
) -> CustomResult < ReverseLookup , errors:: StorageError > {
59
- Err ( errors:: StorageError :: MockDbError . into ( ) )
64
+ self . reverse_lookups
65
+ . lock ( )
66
+ . await
67
+ . iter ( )
68
+ . find ( |reverse_lookup| reverse_lookup. lookup_id == lookup_id)
69
+ . ok_or (
70
+ errors:: StorageError :: ValueNotFound ( format ! (
71
+ "No reverse lookup found for lookup_id = {}" ,
72
+ lookup_id
73
+ ) )
74
+ . into ( ) ,
75
+ )
76
+ . cloned ( )
60
77
}
61
78
}
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ pub struct MockDb {
39
39
pub captures : Arc < Mutex < Vec < crate :: store:: capture:: Capture > > > ,
40
40
pub merchant_key_store : Arc < Mutex < Vec < crate :: store:: merchant_key_store:: MerchantKeyStore > > > ,
41
41
pub business_profiles : Arc < Mutex < Vec < crate :: store:: business_profile:: BusinessProfile > > > ,
42
+ pub reverse_lookups : Arc < Mutex < Vec < store:: ReverseLookup > > > ,
42
43
}
43
44
44
45
impl MockDb {
@@ -70,6 +71,7 @@ impl MockDb {
70
71
captures : Default :: default ( ) ,
71
72
merchant_key_store : Default :: default ( ) ,
72
73
business_profiles : Default :: default ( ) ,
74
+ reverse_lookups : Default :: default ( ) ,
73
75
} )
74
76
}
75
77
}
You can’t perform that action at this time.
0 commit comments