@@ -399,81 +399,133 @@ func CheckListFilesCanonical(t *testing.T, info StoreInfo, canonical string) {
399399 }
400400
401401 t .Run ("List" , func (t * testing.T ) {
402+ // NB: When using AfterKey in tests, pick keys such that they do not exist
403+ // in the expected output to avoid tests flaking due to different cloud
404+ // provider behaviors around AfterKey's inclusiveness.
402405 for _ , tc := range []struct {
403- name string
404- uri string
405- prefix string
406- delimiter string
407- expected []string
406+ name string
407+ uri string
408+ prefix string
409+ opts cloud. ListOptions
410+ expected []string
408411 }{
409412 {
410413 "root" ,
411414 info .URI ,
412415 "" ,
413- "" ,
416+ cloud. ListOptions {} ,
414417 foreach (fileNames , func (s string ) string { return "/" + s }),
415418 },
416419 {
417420 "file-slash-numbers-slash" ,
418421 info .URI ,
419422 "file/numbers/" ,
420- "" ,
423+ cloud. ListOptions {} ,
421424 []string {"data1.csv" , "data2.csv" , "data3.csv" },
422425 },
423426 {
424427 "root-slash" ,
425428 info .URI ,
426429 "/" ,
427- "" ,
430+ cloud. ListOptions {} ,
428431 foreach (fileNames , func (s string ) string { return s }),
429432 },
430433 {
431434 "file" ,
432435 info .URI ,
433436 "file" ,
434- "" ,
437+ cloud. ListOptions {} ,
435438 foreach (fileNames , func (s string ) string { return strings .TrimPrefix (s , "file" ) }),
436439 },
437440 {
438441 "file-slash" ,
439442 info .URI ,
440443 "file/" ,
441- "" ,
444+ cloud. ListOptions {} ,
442445 foreach (fileNames , func (s string ) string { return strings .TrimPrefix (s , "file/" ) }),
443446 },
444447 {
445448 "slash-f" ,
446449 info .URI ,
447450 "/f" ,
448- "" ,
451+ cloud. ListOptions {} ,
449452 foreach (fileNames , func (s string ) string { return strings .TrimPrefix (s , "f" ) }),
450453 },
451454 {
452455 "nothing" ,
453456 info .URI ,
454457 "nothing" ,
455- "" ,
458+ cloud. ListOptions {} ,
456459 nil ,
457460 },
458461 {
459462 "delim-slash-file-slash" ,
460463 info .URI ,
461464 "file/" ,
462- "/" ,
465+ cloud. ListOptions { Delimiter : "/" } ,
463466 []string {"abc/" , "letters/" , "numbers/" },
464467 },
465468 {
466469 "delim-data" ,
467470 info .URI ,
468471 "" ,
469- "data" ,
472+ cloud. ListOptions { Delimiter : "data" } ,
470473 []string {"/file/abc/A.csv" , "/file/abc/B.csv" , "/file/abc/C.csv" , "/file/letters/data" , "/file/numbers/data" },
471474 },
475+ {
476+ "afterkey-no-prefix" ,
477+ info .URI ,
478+ "" ,
479+ cloud.ListOptions {AfterKey : "file/letters/dataB" },
480+ []string {"/file/letters/dataB.csv" , "/file/letters/dataC.csv" , "/file/numbers/data1.csv" , "/file/numbers/data2.csv" , "/file/numbers/data3.csv" },
481+ },
482+ {
483+ "afterkey-with-prefix" ,
484+ info .URI ,
485+ "file/letters/" ,
486+ cloud.ListOptions {AfterKey : "file/letters/dataB" },
487+ []string {"dataB.csv" , "dataC.csv" },
488+ },
489+ {
490+ "afterkey-before-prefix" ,
491+ info .URI ,
492+ "file/numbers/" ,
493+ cloud.ListOptions {AfterKey : "file/abc/D" },
494+ []string {"data1.csv" , "data2.csv" , "data3.csv" },
495+ },
496+ {
497+ "afterkey-after-prefix" ,
498+ info .URI ,
499+ "file/abc/" ,
500+ cloud.ListOptions {AfterKey : "file/z" },
501+ nil ,
502+ },
503+ {
504+ "afterkey-excluded-from-results" ,
505+ info .URI ,
506+ "file/abc/" ,
507+ cloud.ListOptions {AfterKey : "file/abc/B.csv" },
508+ []string {"C.csv" },
509+ },
510+ {
511+ "afterkey-with-delim" ,
512+ info .URI ,
513+ "file/" ,
514+ cloud.ListOptions {Delimiter : "/" , AfterKey : "file/bar" },
515+ []string {"letters/" , "numbers/" },
516+ },
517+ {
518+ "afterkey-applied-after-delim-grouping" ,
519+ info .URI ,
520+ "file/" ,
521+ cloud.ListOptions {Delimiter : "/" , AfterKey : "file/abc/B" },
522+ []string {"letters/" , "numbers/" },
523+ },
472524 } {
473525 t .Run (tc .name , func (t * testing.T ) {
474526 s := storeFromURI (ctx , t , tc .uri , clientFactory , info .User , info .DB , testSettings )
475527 var actual []string
476- require .NoError (t , s .List (ctx , tc .prefix , cloud. ListOptions { Delimiter : tc .delimiter } , func (f string ) error {
528+ require .NoError (t , s .List (ctx , tc .prefix , tc .opts , func (f string ) error {
477529 actual = append (actual , f )
478530 return nil
479531 }))
0 commit comments