@@ -212,7 +212,7 @@ mod tests {
212
212
use crate :: envoy:: RateLimitRequest ;
213
213
use std:: time:: Duration ;
214
214
215
- fn grpc_call_fn_stub (
215
+ fn default_grpc_call_fn_stub (
216
216
_upstream_name : & str ,
217
217
_service_name : & str ,
218
218
_method_name : & str ,
@@ -244,7 +244,7 @@ mod tests {
244
244
}
245
245
}
246
246
247
- fn build_operation ( ) -> Operation {
247
+ fn build_operation ( grpc_call_fn_stub : GrpcCallFn ) -> Operation {
248
248
Operation {
249
249
state : State :: Pending ,
250
250
result : Ok ( 0 ) ,
@@ -260,7 +260,7 @@ mod tests {
260
260
261
261
#[ test]
262
262
fn operation_getters ( ) {
263
- let operation = build_operation ( ) ;
263
+ let operation = build_operation ( default_grpc_call_fn_stub ) ;
264
264
265
265
assert_eq ! ( * operation. get_state( ) , State :: Pending ) ;
266
266
assert_eq ! ( * operation. get_extension_type( ) , ExtensionType :: RateLimit ) ;
@@ -270,7 +270,7 @@ mod tests {
270
270
271
271
#[ test]
272
272
fn operation_transition ( ) {
273
- let mut operation = build_operation ( ) ;
273
+ let mut operation = build_operation ( default_grpc_call_fn_stub ) ;
274
274
assert_eq ! ( operation. result, Ok ( 0 ) ) ;
275
275
assert_eq ! ( * operation. get_state( ) , State :: Pending ) ;
276
276
let mut res = operation. trigger ( ) ;
@@ -287,15 +287,15 @@ mod tests {
287
287
let operation_dispatcher = OperationDispatcher :: default ( ) ;
288
288
289
289
assert_eq ! ( operation_dispatcher. operations. borrow( ) . len( ) , 0 ) ;
290
- operation_dispatcher. push_operations ( vec ! [ build_operation( ) ] ) ;
290
+ operation_dispatcher. push_operations ( vec ! [ build_operation( default_grpc_call_fn_stub ) ] ) ;
291
291
292
292
assert_eq ! ( operation_dispatcher. operations. borrow( ) . len( ) , 1 ) ;
293
293
}
294
294
295
295
#[ test]
296
296
fn operation_dispatcher_get_current_action_state ( ) {
297
297
let operation_dispatcher = OperationDispatcher :: default ( ) ;
298
- operation_dispatcher. push_operations ( vec ! [ build_operation( ) ] ) ;
298
+ operation_dispatcher. push_operations ( vec ! [ build_operation( default_grpc_call_fn_stub ) ] ) ;
299
299
assert_eq ! (
300
300
operation_dispatcher. get_current_operation_state( ) ,
301
301
Some ( State :: Pending )
@@ -305,7 +305,33 @@ mod tests {
305
305
#[ test]
306
306
fn operation_dispatcher_next ( ) {
307
307
let operation_dispatcher = OperationDispatcher :: default ( ) ;
308
- operation_dispatcher. push_operations ( vec ! [ build_operation( ) , build_operation( ) ] ) ;
308
+
309
+ fn grpc_call_fn_stub_66 (
310
+ _upstream_name : & str ,
311
+ _service_name : & str ,
312
+ _method_name : & str ,
313
+ _initial_metadata : Vec < ( & str , & [ u8 ] ) > ,
314
+ _message : Option < & [ u8 ] > ,
315
+ _timeout : Duration ,
316
+ ) -> Result < u32 , Status > {
317
+ Ok ( 66 )
318
+ }
319
+
320
+ fn grpc_call_fn_stub_77 (
321
+ _upstream_name : & str ,
322
+ _service_name : & str ,
323
+ _method_name : & str ,
324
+ _initial_metadata : Vec < ( & str , & [ u8 ] ) > ,
325
+ _message : Option < & [ u8 ] > ,
326
+ _timeout : Duration ,
327
+ ) -> Result < u32 , Status > {
328
+ Ok ( 77 )
329
+ }
330
+
331
+ operation_dispatcher. push_operations ( vec ! [
332
+ build_operation( grpc_call_fn_stub_66) ,
333
+ build_operation( grpc_call_fn_stub_77) ,
334
+ ] ) ;
309
335
310
336
assert_eq ! ( operation_dispatcher. get_current_operation_result( ) , Ok ( 0 ) ) ;
311
337
assert_eq ! (
@@ -318,27 +344,27 @@ mod tests {
318
344
) ;
319
345
320
346
let mut op = operation_dispatcher. next ( ) ;
321
- assert_eq ! ( op. clone( ) . unwrap( ) . get_result( ) , Ok ( 200 ) ) ;
347
+ assert_eq ! ( op. clone( ) . unwrap( ) . get_result( ) , Ok ( 66 ) ) ;
322
348
assert_eq ! ( * op. unwrap( ) . get_state( ) , State :: Waiting ) ;
323
349
assert_eq ! (
324
350
operation_dispatcher. waiting_operations. borrow_mut( ) . len( ) ,
325
351
1
326
352
) ;
327
353
328
354
op = operation_dispatcher. next ( ) ;
329
- assert_eq ! ( op. clone( ) . unwrap( ) . get_result( ) , Ok ( 200 ) ) ;
355
+ assert_eq ! ( op. clone( ) . unwrap( ) . get_result( ) , Ok ( 66 ) ) ;
330
356
assert_eq ! ( * op. unwrap( ) . get_state( ) , State :: Done ) ;
331
357
332
358
op = operation_dispatcher. next ( ) ;
333
- assert_eq ! ( op. clone( ) . unwrap( ) . get_result( ) , Ok ( 200 ) ) ;
359
+ assert_eq ! ( op. clone( ) . unwrap( ) . get_result( ) , Ok ( 77 ) ) ;
334
360
assert_eq ! ( * op. unwrap( ) . get_state( ) , State :: Waiting ) ;
335
361
assert_eq ! (
336
362
operation_dispatcher. waiting_operations. borrow_mut( ) . len( ) ,
337
363
1
338
364
) ;
339
365
340
366
op = operation_dispatcher. next ( ) ;
341
- assert_eq ! ( op. clone( ) . unwrap( ) . get_result( ) , Ok ( 200 ) ) ;
367
+ assert_eq ! ( op. clone( ) . unwrap( ) . get_result( ) , Ok ( 77 ) ) ;
342
368
assert_eq ! ( * op. unwrap( ) . get_state( ) , State :: Done ) ;
343
369
assert_eq ! (
344
370
operation_dispatcher. waiting_operations. borrow_mut( ) . len( ) ,
0 commit comments