@@ -1160,6 +1160,130 @@ mod tests {
1160
1160
) ;
1161
1161
}
1162
1162
1163
+ #[ tokio:: test]
1164
+ async fn test_update_namespace_noop ( ) {
1165
+ let warehouse_loc = temp_path ( ) ;
1166
+ let catalog = new_sql_catalog ( warehouse_loc) . await ;
1167
+ let namespace_ident = NamespaceIdent :: new ( "a" . into ( ) ) ;
1168
+ create_namespace ( & catalog, & namespace_ident) . await ;
1169
+
1170
+ catalog
1171
+ . update_namespace ( & namespace_ident, HashMap :: new ( ) )
1172
+ . await
1173
+ . unwrap ( ) ;
1174
+
1175
+ assert_eq ! (
1176
+ * catalog
1177
+ . get_namespace( & namespace_ident)
1178
+ . await
1179
+ . unwrap( )
1180
+ . properties( ) ,
1181
+ HashMap :: from_iter( [ ( "exists" . to_string( ) , "true" . to_string( ) ) ] )
1182
+ )
1183
+ }
1184
+
1185
+ #[ tokio:: test]
1186
+ async fn test_update_namespace ( ) {
1187
+ let warehouse_loc = temp_path ( ) ;
1188
+ let catalog = new_sql_catalog ( warehouse_loc) . await ;
1189
+ let namespace_ident = NamespaceIdent :: new ( "a" . into ( ) ) ;
1190
+ create_namespace ( & catalog, & namespace_ident) . await ;
1191
+
1192
+ let mut props = HashMap :: from_iter ( [
1193
+ ( "prop1" . to_string ( ) , "val1" . to_string ( ) ) ,
1194
+ ( "prop2" . into ( ) , "val2" . into ( ) ) ,
1195
+ ] ) ;
1196
+
1197
+ catalog
1198
+ . update_namespace ( & namespace_ident, props. clone ( ) )
1199
+ . await
1200
+ . unwrap ( ) ;
1201
+
1202
+ props. insert ( "exists" . into ( ) , "true" . into ( ) ) ;
1203
+
1204
+ assert_eq ! (
1205
+ * catalog
1206
+ . get_namespace( & namespace_ident)
1207
+ . await
1208
+ . unwrap( )
1209
+ . properties( ) ,
1210
+ props
1211
+ )
1212
+ }
1213
+
1214
+ #[ tokio:: test]
1215
+ async fn test_update_nested_namespace ( ) {
1216
+ let warehouse_loc = temp_path ( ) ;
1217
+ let catalog = new_sql_catalog ( warehouse_loc) . await ;
1218
+ let namespace_ident = NamespaceIdent :: from_strs ( [ "a" , "b" ] ) . unwrap ( ) ;
1219
+ create_namespace ( & catalog, & namespace_ident) . await ;
1220
+
1221
+ let mut props = HashMap :: from_iter ( [
1222
+ ( "prop1" . to_string ( ) , "val1" . to_string ( ) ) ,
1223
+ ( "prop2" . into ( ) , "val2" . into ( ) ) ,
1224
+ ] ) ;
1225
+
1226
+ catalog
1227
+ . update_namespace ( & namespace_ident, props. clone ( ) )
1228
+ . await
1229
+ . unwrap ( ) ;
1230
+
1231
+ props. insert ( "exists" . into ( ) , "true" . into ( ) ) ;
1232
+
1233
+ assert_eq ! (
1234
+ * catalog
1235
+ . get_namespace( & namespace_ident)
1236
+ . await
1237
+ . unwrap( )
1238
+ . properties( ) ,
1239
+ props
1240
+ )
1241
+ }
1242
+
1243
+ #[ tokio:: test]
1244
+ async fn test_update_namespace_errors_if_namespace_doesnt_exist ( ) {
1245
+ let warehouse_loc = temp_path ( ) ;
1246
+ let catalog = new_sql_catalog ( warehouse_loc) . await ;
1247
+ let namespace_ident = NamespaceIdent :: new ( "a" . into ( ) ) ;
1248
+
1249
+ let props = HashMap :: from_iter ( [
1250
+ ( "prop1" . to_string ( ) , "val1" . to_string ( ) ) ,
1251
+ ( "prop2" . into ( ) , "val2" . into ( ) ) ,
1252
+ ] ) ;
1253
+
1254
+ let err = catalog
1255
+ . update_namespace ( & namespace_ident, props)
1256
+ . await
1257
+ . unwrap_err ( ) ;
1258
+
1259
+ assert_eq ! (
1260
+ err. message( ) ,
1261
+ format!( "No such namespace: {:?}" , namespace_ident)
1262
+ ) ;
1263
+ }
1264
+
1265
+ #[ tokio:: test]
1266
+ async fn test_update_namespace_errors_if_nested_namespace_doesnt_exist ( ) {
1267
+ let warehouse_loc = temp_path ( ) ;
1268
+ let catalog = new_sql_catalog ( warehouse_loc) . await ;
1269
+ let namespace_ident = NamespaceIdent :: from_strs ( [ "a" , "b" ] ) . unwrap ( ) ;
1270
+
1271
+ let props = HashMap :: from_iter ( [
1272
+ ( "prop1" . to_string ( ) , "val1" . to_string ( ) ) ,
1273
+ ( "prop2" . into ( ) , "val2" . into ( ) ) ,
1274
+ ] ) ;
1275
+
1276
+ let err = catalog
1277
+ . update_namespace ( & namespace_ident, props)
1278
+ . await
1279
+ . unwrap_err ( ) ;
1280
+
1281
+ assert_eq ! (
1282
+ err. message( ) ,
1283
+ format!( "No such namespace: {:?}" , namespace_ident)
1284
+ ) ;
1285
+ }
1286
+
1163
1287
#[ tokio:: test]
1164
1288
async fn test_drop_namespace ( ) {
1165
1289
let warehouse_loc = temp_path ( ) ;
0 commit comments