@@ -167,3 +167,46 @@ impl Operation {
167167 }
168168 }
169169}
170+
171+ mod tests {
172+ use super :: upsert_representations;
173+ use iceberg_rust_spec:: view_metadata:: ViewRepresentation ;
174+
175+ #[ test]
176+ fn test_upsert_representations ( ) {
177+ assert_eq ! (
178+ upsert_representations(
179+ & vec![
180+ ViewRepresentation :: sql( "a1" , Some ( "a" ) ) ,
181+ ViewRepresentation :: sql( "b1" , Some ( "b" ) ) ,
182+ ] ,
183+ & vec![
184+ ViewRepresentation :: sql( "b2" , Some ( "b" ) ) ,
185+ ViewRepresentation :: sql( "c2" , Some ( "c" ) ) ,
186+ ]
187+ ) ,
188+ vec![
189+ ViewRepresentation :: sql( "a1" , Some ( "a" ) ) ,
190+ ViewRepresentation :: sql( "b2" , Some ( "b" ) ) ,
191+ ViewRepresentation :: sql( "c2" , Some ( "c" ) ) ,
192+ ]
193+ ) ;
194+ assert_eq ! (
195+ upsert_representations(
196+ & vec![
197+ ViewRepresentation :: sql( "a1" , Some ( "a" ) ) ,
198+ ViewRepresentation :: sql( "b1" , Some ( "b" ) ) ,
199+ ] ,
200+ & vec![
201+ ViewRepresentation :: sql( "c2" , Some ( "c" ) ) ,
202+ ViewRepresentation :: sql( "a2" , Some ( "a" ) ) ,
203+ ]
204+ ) ,
205+ vec![
206+ ViewRepresentation :: sql( "a2" , Some ( "a" ) ) ,
207+ ViewRepresentation :: sql( "b1" , Some ( "b" ) ) ,
208+ ViewRepresentation :: sql( "c2" , Some ( "c" ) ) ,
209+ ]
210+ ) ;
211+ }
212+ }
0 commit comments