diff options
author | Alex <alex@adnab.me> | 2024-02-09 13:38:17 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2024-02-09 13:38:17 +0000 |
commit | 3865080c354427f913de6f2bb5e5b03f6231751c (patch) | |
tree | e360185ee2a5d2ae5d1246ee6c5e6b161e88e03c /src/garage/tests | |
parent | 0c7ce001c907791518f93fd9d2db01eebc517c51 (diff) | |
parent | 10bc2ead6015bf446451015ee73e902c3fd5e9a9 (diff) | |
download | garage-3865080c354427f913de6f2bb5e5b03f6231751c.tar.gz garage-3865080c354427f913de6f2bb5e5b03f6231751c.zip |
Merge pull request 'Allow multi-character delimiters in List* (fix #692)' (#711) from multi-char-delimiter-692 into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/711
Diffstat (limited to 'src/garage/tests')
-rw-r--r-- | src/garage/tests/s3/list.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/garage/tests/s3/list.rs b/src/garage/tests/s3/list.rs index bb03f250..1b0c006d 100644 --- a/src/garage/tests/s3/list.rs +++ b/src/garage/tests/s3/list.rs @@ -613,3 +613,63 @@ async fn test_listmultipart() { assert!(r.common_prefixes.is_none()); } } + +#[tokio::test] +async fn test_multichar_delimiter() { + // Test case from dpape from issue #692 with reference results from Amazon + + let ctx = common::context(); + let bucket = ctx.create_bucket("multichardelim"); + + for k in [ + "a/", "a/b/", "a/b/c/", "a/b/c/d", "a/c/", "a/c/b/", "a/c/b/e", + ] { + ctx.client + .put_object() + .bucket(&bucket) + .key(k) + .send() + .await + .unwrap(); + } + + // With delimiter / + { + let r = ctx + .client + .list_objects_v2() + .bucket(&bucket) + .delimiter("/") + .send() + .await + .unwrap(); + + assert!(r.contents.is_none()); + + let common_prefixes = r.common_prefixes.unwrap(); + assert_eq!(common_prefixes.len(), 1); + assert_eq!(common_prefixes[0].prefix.as_deref().unwrap(), "a/"); + } + + // With delimiter b/ + { + let r = ctx + .client + .list_objects_v2() + .bucket(&bucket) + .delimiter("b/") + .send() + .await + .unwrap(); + + let contents = r.contents.unwrap(); + assert_eq!(contents.len(), 2); + assert_eq!(contents[0].key.as_deref().unwrap(), "a/"); + assert_eq!(contents[1].key.as_deref().unwrap(), "a/c/"); + + let common_prefixes = r.common_prefixes.unwrap(); + assert_eq!(common_prefixes.len(), 2); + assert_eq!(common_prefixes[0].prefix.as_deref().unwrap(), "a/b/"); + assert_eq!(common_prefixes[1].prefix.as_deref().unwrap(), "a/c/b/"); + } +} |