@@ -3,7 +3,7 @@ use crate::flow_store::connection::FlowStore;
33use async_trait:: async_trait;
44use log:: error;
55use redis:: { AsyncCommands , JsonAsyncCommands , RedisError , RedisResult } ;
6- use tucana:: shared:: { Flow , Flows } ;
6+ use tucana:: shared:: { Flows , ValidationFlow } ;
77
88#[ derive( Debug ) ]
99pub struct FlowStoreError {
@@ -23,7 +23,7 @@ pub enum FlowStoreErrorKind {
2323#[ async_trait]
2424pub trait FlowStoreServiceBase {
2525 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 > ;
2727 async fn insert_flows ( & mut self , flows : Flows ) -> Result < i64 , FlowStoreError > ;
2828 async fn delete_flow ( & mut self , flow_id : i64 ) -> Result < i64 , RedisError > ;
2929 async fn delete_flows ( & mut self , flow_ids : Vec < i64 > ) -> Result < i64 , RedisError > ;
@@ -45,7 +45,7 @@ impl FlowStoreServiceBase for FlowStoreService {
4545 }
4646
4747 /// 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 > {
4949 let mut connection = self . redis_client_arc . lock ( ) . await ;
5050
5151 let identifier = match flow_identifier:: get_flow_identifier ( & flow) {
@@ -175,10 +175,10 @@ impl FlowStoreServiceBase for FlowStoreService {
175175 . await
176176 {
177177 Ok ( json_values) => {
178- let mut all_flows: Vec < Flow > = Vec :: new ( ) ;
178+ let mut all_flows: Vec < ValidationFlow > = Vec :: new ( ) ;
179179
180180 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) {
182182 Ok ( mut flows) => all_flows. append ( & mut flows) ,
183183 Err ( error) => {
184184 return Err ( FlowStoreError {
@@ -207,20 +207,19 @@ impl FlowStoreServiceBase for FlowStoreService {
207207mod tests {
208208 use std:: collections:: HashMap ;
209209
210- use crate :: flow_store:: connection:: create_flow_store_connection;
211210 use crate :: flow_store:: connection:: FlowStore ;
211+ use crate :: flow_store:: connection:: create_flow_store_connection;
212212 use crate :: flow_store:: service:: FlowStoreService ;
213213 use crate :: flow_store:: service:: FlowStoreServiceBase ;
214214 use redis:: { AsyncCommands , JsonAsyncCommands } ;
215215 use serial_test:: serial;
216+ use testcontainers:: GenericImage ;
216217 use testcontainers:: core:: IntoContainerPort ;
217218 use testcontainers:: core:: WaitFor ;
218219 use testcontainers:: runners:: AsyncRunner ;
219- use testcontainers:: GenericImage ;
220220 use tucana:: shared:: FlowSetting ;
221- use tucana:: shared:: FlowSettingDefinition ;
222221 use tucana:: shared:: Struct ;
223- use tucana:: shared:: { Flow , Flows } ;
222+ use tucana:: shared:: { Flows , ValidationFlow } ;
224223
225224 fn get_string_value ( value : & str ) -> tucana:: shared:: Value {
226225 tucana:: shared:: Value {
@@ -233,10 +232,8 @@ mod tests {
233232 fn get_settings ( ) -> Vec < FlowSetting > {
234233 vec ! [
235234 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" ) ,
240237 object: Some ( Struct {
241238 fields: {
242239 let mut map = HashMap :: new( ) ;
@@ -246,10 +243,8 @@ mod tests {
246243 } ) ,
247244 } ,
248245 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" ) ,
253248 object: Some ( Struct {
254249 fields: {
255250 let mut map = HashMap :: new( ) ;
@@ -304,7 +299,7 @@ mod tests {
304299 redis_integration_test ! (
305300 insert_one_flow,
306301 ( |connection: FlowStore , mut service: FlowStoreService | async move {
307- let flow = Flow {
302+ let flow = ValidationFlow {
308303 flow_id: 1 ,
309304 r#type: "REST" . to_string( ) ,
310305 settings: get_settings( ) ,
@@ -331,15 +326,16 @@ mod tests {
331326 println!( "{}" , redis_result. clone( ) . unwrap( ) ) ;
332327
333328 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( ) ;
335331 assert_eq!( redis_flow[ 0 ] , flow) ;
336332 } )
337333 ) ;
338334
339335 redis_integration_test ! (
340336 insert_one_flow_fails_no_identifier,
341337 ( |_connection: FlowStore , mut service: FlowStoreService | async move {
342- let flow = Flow {
338+ let flow = ValidationFlow {
343339 flow_id: 1 ,
344340 r#type: "" . to_string( ) ,
345341 settings: get_settings( ) ,
@@ -357,7 +353,7 @@ mod tests {
357353 redis_integration_test ! (
358354 insert_will_overwrite_existing_flow,
359355 ( |connection: FlowStore , mut service: FlowStoreService | async move {
360- let flow = Flow {
356+ let flow = ValidationFlow {
361357 flow_id: 1 ,
362358 r#type: "REST" . to_string( ) ,
363359 settings: get_settings( ) ,
@@ -373,7 +369,7 @@ mod tests {
373369 Err ( err) => println!( "{}" , err. reason) ,
374370 } ;
375371
376- let flow_overwrite = Flow {
372+ let flow_overwrite = ValidationFlow {
377373 flow_id: 1 ,
378374 r#type: "REST" . to_string( ) ,
379375 settings: get_settings( ) ,
@@ -398,15 +394,15 @@ mod tests {
398394
399395 assert_eq!( redis_result. len( ) , 1 ) ;
400396 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( ) ;
402398 assert!( redis_flow[ 0 ] . r#input_type_identifier. is_some( ) ) ;
403399 } )
404400 ) ;
405401
406402 redis_integration_test ! (
407403 insert_many_flows,
408404 ( |_connection: FlowStore , mut service: FlowStoreService | async move {
409- let flow_one = Flow {
405+ let flow_one = ValidationFlow {
410406 flow_id: 1 ,
411407 r#type: "REST" . to_string( ) ,
412408 settings: get_settings( ) ,
@@ -417,7 +413,7 @@ mod tests {
417413 starting_node: None ,
418414 } ;
419415
420- let flow_two = Flow {
416+ let flow_two = ValidationFlow {
421417 flow_id: 2 ,
422418 r#type: "REST" . to_string( ) ,
423419 settings: get_settings( ) ,
@@ -428,7 +424,7 @@ mod tests {
428424 starting_node: None ,
429425 } ;
430426
431- let flow_three = Flow {
427+ let flow_three = ValidationFlow {
432428 flow_id: 3 ,
433429 r#type: "REST" . to_string( ) ,
434430 settings: get_settings( ) ,
@@ -450,7 +446,7 @@ mod tests {
450446 redis_integration_test ! (
451447 delete_one_existing_flow,
452448 ( |connection: FlowStore , mut service: FlowStoreService | async move {
453- let flow = Flow {
449+ let flow = ValidationFlow {
454450 flow_id: 1 ,
455451 r#type: "REST" . to_string( ) ,
456452 settings: get_settings( ) ,
@@ -490,7 +486,7 @@ mod tests {
490486 redis_integration_test ! (
491487 delete_many_existing_flows,
492488 ( |_connection: FlowStore , mut service: FlowStoreService | async move {
493- let flow_one = Flow {
489+ let flow_one = ValidationFlow {
494490 flow_id: 1 ,
495491 r#type: "REST" . to_string( ) ,
496492 settings: get_settings( ) ,
@@ -501,7 +497,7 @@ mod tests {
501497 project_id: 1 ,
502498 } ;
503499
504- let flow_two = Flow {
500+ let flow_two = ValidationFlow {
505501 flow_id: 2 ,
506502 r#type: "REST" . to_string( ) ,
507503 settings: get_settings( ) ,
@@ -512,7 +508,7 @@ mod tests {
512508 project_id: 1 ,
513509 } ;
514510
515- let flow_three = Flow {
511+ let flow_three = ValidationFlow {
516512 flow_id: 3 ,
517513 r#type: "REST" . to_string( ) ,
518514 settings: get_settings( ) ,
@@ -545,7 +541,7 @@ mod tests {
545541 redis_integration_test ! (
546542 get_existing_flow_ids,
547543 ( |_connection: FlowStore , mut service: FlowStoreService | async move {
548- let flow_one = Flow {
544+ let flow_one = ValidationFlow {
549545 flow_id: 1 ,
550546 r#type: "REST" . to_string( ) ,
551547 settings: get_settings( ) ,
@@ -556,7 +552,7 @@ mod tests {
556552 project_id: 1 ,
557553 } ;
558554
559- let flow_two = Flow {
555+ let flow_two = ValidationFlow {
560556 flow_id: 2 ,
561557 r#type: "REST" . to_string( ) ,
562558 settings: get_settings( ) ,
@@ -567,7 +563,7 @@ mod tests {
567563 project_id: 1 ,
568564 } ;
569565
570- let flow_three = Flow {
566+ let flow_three = ValidationFlow {
571567 flow_id: 3 ,
572568 r#type: "REST" . to_string( ) ,
573569 settings: get_settings( ) ,
@@ -611,7 +607,7 @@ mod tests {
611607 redis_integration_test ! (
612608 query_all_flows,
613609 ( |_connection: FlowStore , mut service: FlowStoreService | async move {
614- let flow_one = Flow {
610+ let flow_one = ValidationFlow {
615611 flow_id: 1 ,
616612 r#type: "REST" . to_string( ) ,
617613 settings: get_settings( ) ,
@@ -622,7 +618,7 @@ mod tests {
622618 project_id: 1 ,
623619 } ;
624620
625- let flow_two = Flow {
621+ let flow_two = ValidationFlow {
626622 flow_id: 2 ,
627623 r#type: "REST" . to_string( ) ,
628624 settings: get_settings( ) ,
@@ -633,7 +629,7 @@ mod tests {
633629 project_id: 1 ,
634630 } ;
635631
636- let flow_three = Flow {
632+ let flow_three = ValidationFlow {
637633 flow_id: 3 ,
638634 r#type: "REST" . to_string( ) ,
639635 settings: get_settings( ) ,
@@ -667,7 +663,7 @@ mod tests {
667663 redis_integration_test ! (
668664 query_one_existing_flow,
669665 ( |_connection: FlowStore , mut service: FlowStoreService | async move {
670- let flow_one = Flow {
666+ let flow_one = ValidationFlow {
671667 flow_id: 1 ,
672668 r#type: "REST" . to_string( ) ,
673669 settings: get_settings( ) ,
@@ -678,7 +674,7 @@ mod tests {
678674 project_id: 1 ,
679675 } ;
680676
681- let flow_two = Flow {
677+ let flow_two = ValidationFlow {
682678 flow_id: 2 ,
683679 r#type: "REST" . to_string( ) ,
684680 settings: get_settings( ) ,
@@ -689,7 +685,7 @@ mod tests {
689685 project_id: 1 ,
690686 } ;
691687
692- let flow_three = Flow {
688+ let flow_three = ValidationFlow {
693689 flow_id: 3 ,
694690 r#type: "REST" . to_string( ) ,
695691 settings: get_settings( ) ,
0 commit comments