@@ -3,7 +3,7 @@ use crate::flow_store::connection::FlowStore;
3
3
use async_trait:: async_trait;
4
4
use log:: error;
5
5
use redis:: { AsyncCommands , JsonAsyncCommands , RedisError , RedisResult } ;
6
- use tucana:: shared:: { Flow , Flows } ;
6
+ use tucana:: shared:: { Flows , ValidationFlow } ;
7
7
8
8
#[ derive( Debug ) ]
9
9
pub struct FlowStoreError {
@@ -23,7 +23,7 @@ pub enum FlowStoreErrorKind {
23
23
#[ async_trait]
24
24
pub trait FlowStoreServiceBase {
25
25
async fn new ( redis_client_arc : FlowStore ) -> Self ;
26
- async fn insert_flow ( & mut self , flow : Flow ) -> Result < i64 , FlowStoreError > ;
26
+ async fn insert_flow ( & mut self , flow : ValidationFlow ) -> Result < i64 , FlowStoreError > ;
27
27
async fn insert_flows ( & mut self , flows : Flows ) -> Result < i64 , FlowStoreError > ;
28
28
async fn delete_flow ( & mut self , flow_id : i64 ) -> Result < i64 , RedisError > ;
29
29
async fn delete_flows ( & mut self , flow_ids : Vec < i64 > ) -> Result < i64 , RedisError > ;
@@ -45,7 +45,7 @@ impl FlowStoreServiceBase for FlowStoreService {
45
45
}
46
46
47
47
/// Insert a list of flows into Redis
48
- async fn insert_flow ( & mut self , flow : Flow ) -> Result < i64 , FlowStoreError > {
48
+ async fn insert_flow ( & mut self , flow : ValidationFlow ) -> Result < i64 , FlowStoreError > {
49
49
let mut connection = self . redis_client_arc . lock ( ) . await ;
50
50
51
51
let identifier = match flow_identifier:: get_flow_identifier ( & flow) {
@@ -175,10 +175,10 @@ impl FlowStoreServiceBase for FlowStoreService {
175
175
. await
176
176
{
177
177
Ok ( json_values) => {
178
- let mut all_flows: Vec < Flow > = Vec :: new ( ) ;
178
+ let mut all_flows: Vec < ValidationFlow > = Vec :: new ( ) ;
179
179
180
180
for json_str in json_values {
181
- match serde_json:: from_str :: < Vec < Flow > > ( & json_str) {
181
+ match serde_json:: from_str :: < Vec < ValidationFlow > > ( & json_str) {
182
182
Ok ( mut flows) => all_flows. append ( & mut flows) ,
183
183
Err ( error) => {
184
184
return Err ( FlowStoreError {
@@ -207,20 +207,19 @@ impl FlowStoreServiceBase for FlowStoreService {
207
207
mod tests {
208
208
use std:: collections:: HashMap ;
209
209
210
- use crate :: flow_store:: connection:: create_flow_store_connection;
211
210
use crate :: flow_store:: connection:: FlowStore ;
211
+ use crate :: flow_store:: connection:: create_flow_store_connection;
212
212
use crate :: flow_store:: service:: FlowStoreService ;
213
213
use crate :: flow_store:: service:: FlowStoreServiceBase ;
214
214
use redis:: { AsyncCommands , JsonAsyncCommands } ;
215
215
use serial_test:: serial;
216
+ use testcontainers:: GenericImage ;
216
217
use testcontainers:: core:: IntoContainerPort ;
217
218
use testcontainers:: core:: WaitFor ;
218
219
use testcontainers:: runners:: AsyncRunner ;
219
- use testcontainers:: GenericImage ;
220
220
use tucana:: shared:: FlowSetting ;
221
- use tucana:: shared:: FlowSettingDefinition ;
222
221
use tucana:: shared:: Struct ;
223
- use tucana:: shared:: { Flow , Flows } ;
222
+ use tucana:: shared:: { Flows , ValidationFlow } ;
224
223
225
224
fn get_string_value ( value : & str ) -> tucana:: shared:: Value {
226
225
tucana:: shared:: Value {
@@ -233,10 +232,8 @@ mod tests {
233
232
fn get_settings ( ) -> Vec < FlowSetting > {
234
233
vec ! [
235
234
FlowSetting {
236
- definition: Some ( FlowSettingDefinition {
237
- id: String :: from( "1424525" ) ,
238
- key: String :: from( "HTTP_HOST" ) ,
239
- } ) ,
235
+ database_id: 1234567 ,
236
+ flow_setting_id: String :: from( "HTTP_HOST" ) ,
240
237
object: Some ( Struct {
241
238
fields: {
242
239
let mut map = HashMap :: new( ) ;
@@ -246,10 +243,8 @@ mod tests {
246
243
} ) ,
247
244
} ,
248
245
FlowSetting {
249
- definition: Some ( FlowSettingDefinition {
250
- id: String :: from( "14245252352" ) ,
251
- key: String :: from( "HTTP_METHOD" ) ,
252
- } ) ,
246
+ database_id: 14245252352 ,
247
+ flow_setting_id: String :: from( "HTTP_METHOD" ) ,
253
248
object: Some ( Struct {
254
249
fields: {
255
250
let mut map = HashMap :: new( ) ;
@@ -304,7 +299,7 @@ mod tests {
304
299
redis_integration_test ! (
305
300
insert_one_flow,
306
301
( |connection: FlowStore , mut service: FlowStoreService | async move {
307
- let flow = Flow {
302
+ let flow = ValidationFlow {
308
303
flow_id: 1 ,
309
304
r#type: "REST" . to_string( ) ,
310
305
settings: get_settings( ) ,
@@ -331,15 +326,16 @@ mod tests {
331
326
println!( "{}" , redis_result. clone( ) . unwrap( ) ) ;
332
327
333
328
assert!( redis_result. is_some( ) ) ;
334
- let redis_flow: Vec <Flow > = serde_json:: from_str( & * redis_result. unwrap( ) ) . unwrap( ) ;
329
+ let redis_flow: Vec <ValidationFlow > =
330
+ serde_json:: from_str( & * redis_result. unwrap( ) ) . unwrap( ) ;
335
331
assert_eq!( redis_flow[ 0 ] , flow) ;
336
332
} )
337
333
) ;
338
334
339
335
redis_integration_test ! (
340
336
insert_one_flow_fails_no_identifier,
341
337
( |_connection: FlowStore , mut service: FlowStoreService | async move {
342
- let flow = Flow {
338
+ let flow = ValidationFlow {
343
339
flow_id: 1 ,
344
340
r#type: "" . to_string( ) ,
345
341
settings: get_settings( ) ,
@@ -357,7 +353,7 @@ mod tests {
357
353
redis_integration_test ! (
358
354
insert_will_overwrite_existing_flow,
359
355
( |connection: FlowStore , mut service: FlowStoreService | async move {
360
- let flow = Flow {
356
+ let flow = ValidationFlow {
361
357
flow_id: 1 ,
362
358
r#type: "REST" . to_string( ) ,
363
359
settings: get_settings( ) ,
@@ -373,7 +369,7 @@ mod tests {
373
369
Err ( err) => println!( "{}" , err. reason) ,
374
370
} ;
375
371
376
- let flow_overwrite = Flow {
372
+ let flow_overwrite = ValidationFlow {
377
373
flow_id: 1 ,
378
374
r#type: "REST" . to_string( ) ,
379
375
settings: get_settings( ) ,
@@ -398,15 +394,15 @@ mod tests {
398
394
399
395
assert_eq!( redis_result. len( ) , 1 ) ;
400
396
let string: & str = & * redis_result[ 0 ] ;
401
- let redis_flow: Vec <Flow > = serde_json:: from_str( string) . unwrap( ) ;
397
+ let redis_flow: Vec <ValidationFlow > = serde_json:: from_str( string) . unwrap( ) ;
402
398
assert!( redis_flow[ 0 ] . r#input_type_identifier. is_some( ) ) ;
403
399
} )
404
400
) ;
405
401
406
402
redis_integration_test ! (
407
403
insert_many_flows,
408
404
( |_connection: FlowStore , mut service: FlowStoreService | async move {
409
- let flow_one = Flow {
405
+ let flow_one = ValidationFlow {
410
406
flow_id: 1 ,
411
407
r#type: "REST" . to_string( ) ,
412
408
settings: get_settings( ) ,
@@ -417,7 +413,7 @@ mod tests {
417
413
starting_node: None ,
418
414
} ;
419
415
420
- let flow_two = Flow {
416
+ let flow_two = ValidationFlow {
421
417
flow_id: 2 ,
422
418
r#type: "REST" . to_string( ) ,
423
419
settings: get_settings( ) ,
@@ -428,7 +424,7 @@ mod tests {
428
424
starting_node: None ,
429
425
} ;
430
426
431
- let flow_three = Flow {
427
+ let flow_three = ValidationFlow {
432
428
flow_id: 3 ,
433
429
r#type: "REST" . to_string( ) ,
434
430
settings: get_settings( ) ,
@@ -450,7 +446,7 @@ mod tests {
450
446
redis_integration_test ! (
451
447
delete_one_existing_flow,
452
448
( |connection: FlowStore , mut service: FlowStoreService | async move {
453
- let flow = Flow {
449
+ let flow = ValidationFlow {
454
450
flow_id: 1 ,
455
451
r#type: "REST" . to_string( ) ,
456
452
settings: get_settings( ) ,
@@ -490,7 +486,7 @@ mod tests {
490
486
redis_integration_test ! (
491
487
delete_many_existing_flows,
492
488
( |_connection: FlowStore , mut service: FlowStoreService | async move {
493
- let flow_one = Flow {
489
+ let flow_one = ValidationFlow {
494
490
flow_id: 1 ,
495
491
r#type: "REST" . to_string( ) ,
496
492
settings: get_settings( ) ,
@@ -501,7 +497,7 @@ mod tests {
501
497
project_id: 1 ,
502
498
} ;
503
499
504
- let flow_two = Flow {
500
+ let flow_two = ValidationFlow {
505
501
flow_id: 2 ,
506
502
r#type: "REST" . to_string( ) ,
507
503
settings: get_settings( ) ,
@@ -512,7 +508,7 @@ mod tests {
512
508
project_id: 1 ,
513
509
} ;
514
510
515
- let flow_three = Flow {
511
+ let flow_three = ValidationFlow {
516
512
flow_id: 3 ,
517
513
r#type: "REST" . to_string( ) ,
518
514
settings: get_settings( ) ,
@@ -545,7 +541,7 @@ mod tests {
545
541
redis_integration_test ! (
546
542
get_existing_flow_ids,
547
543
( |_connection: FlowStore , mut service: FlowStoreService | async move {
548
- let flow_one = Flow {
544
+ let flow_one = ValidationFlow {
549
545
flow_id: 1 ,
550
546
r#type: "REST" . to_string( ) ,
551
547
settings: get_settings( ) ,
@@ -556,7 +552,7 @@ mod tests {
556
552
project_id: 1 ,
557
553
} ;
558
554
559
- let flow_two = Flow {
555
+ let flow_two = ValidationFlow {
560
556
flow_id: 2 ,
561
557
r#type: "REST" . to_string( ) ,
562
558
settings: get_settings( ) ,
@@ -567,7 +563,7 @@ mod tests {
567
563
project_id: 1 ,
568
564
} ;
569
565
570
- let flow_three = Flow {
566
+ let flow_three = ValidationFlow {
571
567
flow_id: 3 ,
572
568
r#type: "REST" . to_string( ) ,
573
569
settings: get_settings( ) ,
@@ -611,7 +607,7 @@ mod tests {
611
607
redis_integration_test ! (
612
608
query_all_flows,
613
609
( |_connection: FlowStore , mut service: FlowStoreService | async move {
614
- let flow_one = Flow {
610
+ let flow_one = ValidationFlow {
615
611
flow_id: 1 ,
616
612
r#type: "REST" . to_string( ) ,
617
613
settings: get_settings( ) ,
@@ -622,7 +618,7 @@ mod tests {
622
618
project_id: 1 ,
623
619
} ;
624
620
625
- let flow_two = Flow {
621
+ let flow_two = ValidationFlow {
626
622
flow_id: 2 ,
627
623
r#type: "REST" . to_string( ) ,
628
624
settings: get_settings( ) ,
@@ -633,7 +629,7 @@ mod tests {
633
629
project_id: 1 ,
634
630
} ;
635
631
636
- let flow_three = Flow {
632
+ let flow_three = ValidationFlow {
637
633
flow_id: 3 ,
638
634
r#type: "REST" . to_string( ) ,
639
635
settings: get_settings( ) ,
@@ -667,7 +663,7 @@ mod tests {
667
663
redis_integration_test ! (
668
664
query_one_existing_flow,
669
665
( |_connection: FlowStore , mut service: FlowStoreService | async move {
670
- let flow_one = Flow {
666
+ let flow_one = ValidationFlow {
671
667
flow_id: 1 ,
672
668
r#type: "REST" . to_string( ) ,
673
669
settings: get_settings( ) ,
@@ -678,7 +674,7 @@ mod tests {
678
674
project_id: 1 ,
679
675
} ;
680
676
681
- let flow_two = Flow {
677
+ let flow_two = ValidationFlow {
682
678
flow_id: 2 ,
683
679
r#type: "REST" . to_string( ) ,
684
680
settings: get_settings( ) ,
@@ -689,7 +685,7 @@ mod tests {
689
685
project_id: 1 ,
690
686
} ;
691
687
692
- let flow_three = Flow {
688
+ let flow_three = ValidationFlow {
693
689
flow_id: 3 ,
694
690
r#type: "REST" . to_string( ) ,
695
691
settings: get_settings( ) ,
0 commit comments