@@ -18,9 +18,10 @@ use crate::pb::insert_remove_sd_card_request::SdCardAction;
18
18
19
19
use pb:: response:: Response ;
20
20
21
- use crate :: workflow:: sdcard ;
21
+ use crate :: workflow:: Workflows ;
22
22
23
- pub async fn process (
23
+ pub async fn process < W : Workflows > (
24
+ workflows : & mut W ,
24
25
& pb:: InsertRemoveSdCardRequest { action } : & pb:: InsertRemoveSdCardRequest ,
25
26
) -> Result < Response , Error > {
26
27
let inserted = bitbox02:: sd:: sdcard_inserted ( ) ;
@@ -31,7 +32,7 @@ pub async fn process(
31
32
if inserted {
32
33
return Ok ( Response :: Success ( pb:: Success { } ) ) ;
33
34
}
34
- sdcard :: sdcard ( ) . await ?;
35
+ workflows . insert_sdcard ( ) . await ?;
35
36
Ok ( Response :: Success ( pb:: Success { } ) )
36
37
}
37
38
@@ -40,6 +41,7 @@ mod tests {
40
41
use super :: * ;
41
42
42
43
use crate :: bb02_async:: block_on;
44
+ use crate :: workflow:: testing:: TestingWorkflows ;
43
45
use alloc:: boxed:: Box ;
44
46
use bitbox02:: testing:: { mock, Data } ;
45
47
@@ -51,9 +53,12 @@ mod tests {
51
53
..Default :: default ( )
52
54
} ) ;
53
55
assert_eq ! (
54
- block_on( process( & pb:: InsertRemoveSdCardRequest {
55
- action: SdCardAction :: InsertCard as _,
56
- } ) ) ,
56
+ block_on( process(
57
+ & mut TestingWorkflows :: new( ) ,
58
+ & pb:: InsertRemoveSdCardRequest {
59
+ action: SdCardAction :: InsertCard as _,
60
+ }
61
+ ) ) ,
57
62
Ok ( Response :: Success ( pb:: Success { } ) )
58
63
) ;
59
64
@@ -63,9 +68,12 @@ mod tests {
63
68
..Default :: default ( )
64
69
} ) ;
65
70
assert_eq ! (
66
- block_on( process( & pb:: InsertRemoveSdCardRequest {
67
- action: SdCardAction :: RemoveCard as _,
68
- } ) ) ,
71
+ block_on( process(
72
+ & mut TestingWorkflows :: new( ) ,
73
+ & pb:: InsertRemoveSdCardRequest {
74
+ action: SdCardAction :: RemoveCard as _,
75
+ }
76
+ ) ) ,
69
77
Ok ( Response :: Success ( pb:: Success { } ) )
70
78
) ;
71
79
@@ -75,9 +83,12 @@ mod tests {
75
83
..Default :: default ( )
76
84
} ) ;
77
85
assert_eq ! (
78
- block_on( process( & pb:: InsertRemoveSdCardRequest {
79
- action: SdCardAction :: InsertCard as _,
80
- } ) ) ,
86
+ block_on( process(
87
+ & mut TestingWorkflows :: new( ) ,
88
+ & pb:: InsertRemoveSdCardRequest {
89
+ action: SdCardAction :: InsertCard as _,
90
+ }
91
+ ) ) ,
81
92
Ok ( Response :: Success ( pb:: Success { } ) )
82
93
) ;
83
94
@@ -87,9 +98,12 @@ mod tests {
87
98
..Default :: default ( )
88
99
} ) ;
89
100
assert_eq ! (
90
- block_on( process( & pb:: InsertRemoveSdCardRequest {
91
- action: SdCardAction :: RemoveCard as _,
92
- } ) ) ,
101
+ block_on( process(
102
+ & mut TestingWorkflows :: new( ) ,
103
+ & pb:: InsertRemoveSdCardRequest {
104
+ action: SdCardAction :: RemoveCard as _,
105
+ }
106
+ ) ) ,
93
107
Ok ( Response :: Success ( pb:: Success { } ) )
94
108
) ;
95
109
}
0 commit comments