@@ -84,3 +84,62 @@ pub(super) async fn validate_existing_table_compatibility(
8484
8585 Ok ( ( ) )
8686}
87+
88+ #[ cfg( test) ]
89+ mod tests {
90+ use super :: validate_data_compatibility;
91+ use crate :: manifest:: { Manifest , ManifestObject } ;
92+ use crate :: types:: DataFormat ;
93+
94+ fn manifest_for_compat ( data_format : DataFormat , source_pg_version_num : i32 ) -> Manifest {
95+ Manifest {
96+ format_version : 1 ,
97+ created_at : "2026-02-19T10:00:00Z" . to_owned ( ) ,
98+ source_fingerprint : Some ( "database=app user=app" . to_owned ( ) ) ,
99+ source_pg_version_num,
100+ data_format,
101+ consistent_snapshot : true ,
102+ objects : vec ! [ ManifestObject {
103+ kind: "table" . to_owned( ) ,
104+ source_schema: "public" . to_owned( ) ,
105+ source_name: "orders" . to_owned( ) ,
106+ target_schema: "archive" . to_owned( ) ,
107+ target_name: "orders" . to_owned( ) ,
108+ source_select: "select * from public.orders" . to_owned( ) ,
109+ normalized_select: "SELECT \" id\" FROM \" public\" .\" orders\" " . to_owned( ) ,
110+ ddl_path: "ddl/0001__public.orders.sql" . to_owned( ) ,
111+ data_path: "data/0001__public.orders.copybin" . to_owned( ) ,
112+ effective_columns: vec![ "id" . to_owned( ) ] ,
113+ effective_column_types: vec![ "bigint" . to_owned( ) ] ,
114+ column_projection: "*" . to_owned( ) ,
115+ row_estimate: Some ( 10 ) ,
116+ } ] ,
117+ }
118+ }
119+
120+ #[ test]
121+ fn binary_compatibility_passes_for_same_major ( ) {
122+ let manifest = manifest_for_compat ( DataFormat :: Binary , 150002 ) ;
123+ validate_data_compatibility ( & manifest, 150099 )
124+ . expect ( "binary format should be compatible on same major version" ) ;
125+ }
126+
127+ #[ test]
128+ fn binary_compatibility_fails_for_different_major ( ) {
129+ let manifest = manifest_for_compat ( DataFormat :: Binary , 140012 ) ;
130+ let error = validate_data_compatibility ( & manifest, 150001 )
131+ . expect_err ( "binary format must fail across major versions" ) ;
132+ assert ! (
133+ error
134+ . to_string( )
135+ . contains( "binary COPY compatibility check failed" )
136+ ) ;
137+ }
138+
139+ #[ test]
140+ fn csv_compatibility_ignores_major_version_difference ( ) {
141+ let manifest = manifest_for_compat ( DataFormat :: Csv , 140012 ) ;
142+ validate_data_compatibility ( & manifest, 160003 )
143+ . expect ( "csv format should ignore major version difference" ) ;
144+ }
145+ }
0 commit comments