@@ -276,51 +276,64 @@ fn test_fdb_axes() {
276276
277277 let fdb = Fdb :: open ( Some ( & config) , None ) . expect ( "failed to create FDB from YAML" ) ;
278278
279- // Archive some data first
280279 let grib_path = fixtures_dir ( ) . join ( "template.grib" ) ;
281280 let grib_data = fs:: read ( & grib_path) . expect ( "failed to read template.grib" ) ;
282281
283- let key = Key :: new ( )
284- . with ( "class" , "rd" )
285- . with ( "expver" , "xxxx" )
286- . with ( "stream" , "oper" )
287- . with ( "date" , "20230508" )
288- . with ( "time" , "1200" )
289- . with ( "type" , "fc" )
290- . with ( "levtype" , "sfc" )
291- . with ( "step" , "0" )
292- . with ( "param" , "151130" ) ;
293-
294- fdb. archive ( & key, & grib_data) . expect ( "failed to archive" ) ;
282+ // Archive four fields that share every key except `step`, so the
283+ // axes query returns a real span for at least one keyword.
284+ let steps = [ "0" , "3" , "6" , "9" ] ;
285+ for step in & steps {
286+ let key = Key :: new ( )
287+ . with ( "class" , "rd" )
288+ . with ( "expver" , "xxxx" )
289+ . with ( "stream" , "oper" )
290+ . with ( "date" , "20230508" )
291+ . with ( "time" , "1200" )
292+ . with ( "type" , "fc" )
293+ . with ( "levtype" , "sfc" )
294+ . with ( "step" , step)
295+ . with ( "param" , "151130" ) ;
296+ fdb. archive ( & key, & grib_data) . expect ( "failed to archive" ) ;
297+ }
295298 fdb. flush ( ) . expect ( "flush failed" ) ;
296299
297- // Query axes
298300 let request = Request :: new ( ) . with ( "class" , "rd" ) . with ( "expver" , "xxxx" ) ;
299301 let axes = fdb. axes ( & request, 3 ) . expect ( "failed to get axes" ) ;
300302
301- // We archived exactly one field, so each axis the schema covers
302- // should be present with exactly the value from the key .
303- let expected : & [ ( & str , & str ) ] = & [
303+ // Single-valued axes: each must contain exactly one value matching
304+ // the key we archived (no extra crud allowed) .
305+ let single_valued : & [ ( & str , & str ) ] = & [
304306 ( "class" , "rd" ) ,
305307 ( "expver" , "xxxx" ) ,
306308 ( "stream" , "oper" ) ,
307309 ( "date" , "20230508" ) ,
308310 ( "time" , "1200" ) ,
309311 ( "type" , "fc" ) ,
310312 ( "levtype" , "sfc" ) ,
311- ( "step" , "0" ) ,
312313 ( "param" , "151130" ) ,
313314 ] ;
314315
315- for ( axis, value) in expected {
316+ for ( axis, value) in single_valued {
316317 let values = axes
317318 . get ( * axis)
318319 . unwrap_or_else ( || panic ! ( "axis {axis:?} missing from axes() result: {axes:#?}" ) ) ;
319- assert ! (
320- values. iter( ) . any( |v| v == value) ,
321- "axis {axis:?} does not contain expected value {value:?} (got {values:?})"
320+ assert_eq ! (
321+ values,
322+ & [ value. to_string( ) ] ,
323+ "axis {axis:?}: expected exactly [{value:?}], got {values:?}"
322324 ) ;
323325 }
326+
327+ // Multi-valued axis: `step` should contain exactly the four values
328+ // we archived, in any order.
329+ let step_values = axes
330+ . get ( "step" )
331+ . unwrap_or_else ( || panic ! ( "axis \" step\" missing from axes() result: {axes:#?}" ) ) ;
332+ let mut got: Vec < & str > = step_values. iter ( ) . map ( String :: as_str) . collect ( ) ;
333+ got. sort_unstable ( ) ;
334+ let mut want: Vec < & str > = steps. to_vec ( ) ;
335+ want. sort_unstable ( ) ;
336+ assert_eq ! ( got, want, "step axis: expected {want:?}, got {got:?}" ) ;
324337}
325338
326339#[ test]
0 commit comments