@@ -3,7 +3,7 @@ use etl_api::routes::pipelines::{
3
3
GetPipelineVersionResponse , ReadPipelineResponse , ReadPipelinesResponse ,
4
4
RollbackTableStateRequest , RollbackTableStateResponse , RollbackType ,
5
5
SimpleTableReplicationState , UpdatePipelineConfigRequest , UpdatePipelineConfigResponse ,
6
- UpdatePipelineImageRequest , UpdatePipelineRequest ,
6
+ UpdatePipelineRequest , UpdatePipelineVersionRequest ,
7
7
} ;
8
8
use etl_config:: shared:: { BatchConfig , PgConnectionConfig } ;
9
9
use etl_postgres:: sqlx:: test_utils:: drop_pg_database;
@@ -250,7 +250,7 @@ async fn pipeline_with_another_tenants_source_cannot_be_created() {
250
250
let response = app. create_pipeline ( tenant1_id, & pipeline) . await ;
251
251
252
252
// Assert
253
- assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
253
+ assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
254
254
}
255
255
256
256
#[ tokio:: test( flavor = "multi_thread" ) ]
@@ -283,7 +283,7 @@ async fn pipeline_with_another_tenants_destination_cannot_be_created() {
283
283
let response = app. create_pipeline ( tenant1_id, & pipeline) . await ;
284
284
285
285
// Assert
286
- assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
286
+ assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
287
287
}
288
288
289
289
#[ tokio:: test( flavor = "multi_thread" ) ]
@@ -432,7 +432,7 @@ async fn pipeline_with_another_tenants_source_cannot_be_updated() {
432
432
. await ;
433
433
434
434
// Assert
435
- assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
435
+ assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
436
436
}
437
437
438
438
#[ tokio:: test( flavor = "multi_thread" ) ]
@@ -480,7 +480,7 @@ async fn pipeline_with_another_tenants_destination_cannot_be_updated() {
480
480
. await ;
481
481
482
482
// Assert
483
- assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
483
+ assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
484
484
}
485
485
486
486
#[ tokio:: test( flavor = "multi_thread" ) ]
@@ -666,11 +666,11 @@ async fn updating_pipeline_to_duplicate_source_destination_combination_fails() {
666
666
}
667
667
668
668
#[ tokio:: test( flavor = "multi_thread" ) ]
669
- async fn pipeline_image_can_be_updated_with_specific_image ( ) {
669
+ async fn pipeline_version_can_be_updated ( ) {
670
670
init_test_tracing ( ) ;
671
671
// Arrange
672
672
let app = spawn_test_app ( ) . await ;
673
- create_default_image ( & app) . await ;
673
+ let default_image_id = create_default_image ( & app) . await ;
674
674
let tenant_id = & create_tenant ( & app) . await ;
675
675
let source_id = create_source ( & app, tenant_id) . await ;
676
676
let destination_id = create_destination ( & app, tenant_id) . await ;
@@ -685,65 +685,36 @@ async fn pipeline_image_can_be_updated_with_specific_image() {
685
685
. await ;
686
686
687
687
// Act
688
- let update_request = UpdatePipelineImageRequest {
689
- image_id : Some ( 1 ) , // Use the default image ID
688
+ let update_request = UpdatePipelineVersionRequest {
689
+ version_id : default_image_id ,
690
690
} ;
691
691
let response = app
692
- . update_pipeline_image ( tenant_id, pipeline_id, & update_request)
692
+ . update_pipeline_version ( tenant_id, pipeline_id, & update_request)
693
693
. await ;
694
694
695
695
// Assert
696
696
assert ! ( response. status( ) . is_success( ) ) ;
697
697
}
698
698
699
699
#[ tokio:: test( flavor = "multi_thread" ) ]
700
- async fn pipeline_image_can_be_updated_to_default_image ( ) {
701
- init_test_tracing ( ) ;
702
- // Arrange
703
- let app = spawn_test_app ( ) . await ;
704
- create_default_image ( & app) . await ;
705
- let tenant_id = & create_tenant ( & app) . await ;
706
- let source_id = create_source ( & app, tenant_id) . await ;
707
- let destination_id = create_destination ( & app, tenant_id) . await ;
708
-
709
- let pipeline_id = create_pipeline_with_config (
710
- & app,
711
- tenant_id,
712
- source_id,
713
- destination_id,
714
- new_pipeline_config ( ) ,
715
- )
716
- . await ;
717
-
718
- // Act - update to default image (no image_id specified)
719
- let update_request = UpdatePipelineImageRequest { image_id : None } ;
720
- let response = app
721
- . update_pipeline_image ( tenant_id, pipeline_id, & update_request)
722
- . await ;
723
-
724
- // Assert
725
- assert ! ( response. status( ) . is_success( ) ) ;
726
- }
727
-
728
- #[ tokio:: test( flavor = "multi_thread" ) ]
729
- async fn update_image_fails_for_non_existing_pipeline ( ) {
700
+ async fn update_version_fails_for_non_existing_pipeline ( ) {
730
701
init_test_tracing ( ) ;
731
702
// Arrange
732
703
let app = spawn_test_app ( ) . await ;
733
704
let tenant_id = & create_tenant ( & app) . await ;
734
705
735
706
// Act
736
- let update_request = UpdatePipelineImageRequest { image_id : None } ;
707
+ let update_request = UpdatePipelineVersionRequest { version_id : 1 } ;
737
708
let response = app
738
- . update_pipeline_image ( tenant_id, 42 , & update_request)
709
+ . update_pipeline_version ( tenant_id, 42 , & update_request)
739
710
. await ;
740
711
741
712
// Assert
742
713
assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
743
714
}
744
715
745
716
#[ tokio:: test( flavor = "multi_thread" ) ]
746
- async fn update_image_fails_for_non_existing_image ( ) {
717
+ async fn update_version_fails_when_version_is_not_default ( ) {
747
718
init_test_tracing ( ) ;
748
719
// Arrange
749
720
let app = spawn_test_app ( ) . await ;
@@ -761,63 +732,19 @@ async fn update_image_fails_for_non_existing_image() {
761
732
)
762
733
. await ;
763
734
764
- // Act
765
- let update_request = UpdatePipelineImageRequest {
766
- image_id : Some ( 999 ) , // Non-existing image ID
767
- } ;
768
- let response = app
769
- . update_pipeline_image ( tenant_id, pipeline_id, & update_request)
770
- . await ;
735
+ // Create a non-default image
736
+ let non_default_image_id =
737
+ create_image_with_name ( & app, "another/image" . to_string ( ) , false ) . await ;
771
738
772
- // Assert
773
- assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
774
- }
775
-
776
- #[ tokio:: test( flavor = "multi_thread" ) ]
777
- async fn update_image_fails_for_pipeline_from_another_tenant ( ) {
778
- init_test_tracing ( ) ;
779
- // Arrange
780
- let app = spawn_test_app ( ) . await ;
781
- create_default_image ( & app) . await ;
782
- let tenant1_id = & create_tenant ( & app) . await ;
783
-
784
- let source1_id = create_source ( & app, tenant1_id) . await ;
785
- let destination1_id = create_destination ( & app, tenant1_id) . await ;
786
-
787
- let pipeline_id = create_pipeline_with_config (
788
- & app,
789
- tenant1_id,
790
- source1_id,
791
- destination1_id,
792
- new_pipeline_config ( ) ,
793
- )
794
- . await ;
795
-
796
- // Act - Try to update image using wrong tenant credentials
797
- let update_request = UpdatePipelineImageRequest { image_id : None } ;
798
- let response = app
799
- . update_pipeline_image ( "wrong-tenant-id" , pipeline_id, & update_request)
800
- . await ;
801
-
802
- // Assert
803
- assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
804
- }
805
-
806
- #[ tokio:: test( flavor = "multi_thread" ) ]
807
- async fn update_image_fails_when_no_default_image_exists ( ) {
808
- init_test_tracing ( ) ;
809
- // Arrange
810
- let app = spawn_test_app ( ) . await ;
811
- // Don't create default image
812
- let tenant_id = & create_tenant ( & app) . await ;
813
-
814
- // Act - Try to update to default image when none exists
815
- let update_request = UpdatePipelineImageRequest { image_id : None } ;
739
+ // Act - attempt update with a non-default image id
740
+ let update_request = UpdatePipelineVersionRequest {
741
+ version_id : non_default_image_id,
742
+ } ;
816
743
let response = app
817
- . update_pipeline_image ( tenant_id, 1 , & update_request)
744
+ . update_pipeline_version ( tenant_id, pipeline_id , & update_request)
818
745
. await ;
819
746
820
- // Assert
747
+ // Assert - mismatching image id should be rejected
821
748
assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
822
749
}
823
750
@@ -906,6 +833,7 @@ async fn update_config_fails_for_pipeline_from_another_tenant() {
906
833
init_test_tracing ( ) ;
907
834
// Arrange
908
835
let app = spawn_test_app ( ) . await ;
836
+ create_default_image ( & app) . await ;
909
837
let tenant1_id = & create_tenant ( & app) . await ;
910
838
911
839
let source1_id = create_source ( & app, tenant1_id) . await ;
0 commit comments