diff options
author | Alex Auvolat <alex@adnab.me> | 2024-02-09 14:15:29 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2024-02-09 14:15:29 +0100 |
commit | 10bc2ead6015bf446451015ee73e902c3fd5e9a9 (patch) | |
tree | e360185ee2a5d2ae5d1246ee6c5e6b161e88e03c /src/garage/tests/s3 | |
parent | 0c7ce001c907791518f93fd9d2db01eebc517c51 (diff) | |
download | garage-10bc2ead6015bf446451015ee73e902c3fd5e9a9.tar.gz garage-10bc2ead6015bf446451015ee73e902c3fd5e9a9.zip |
[multi-char-delimiter-692] allow multi-character delimiters in List* (fix #692)
Diffstat (limited to 'src/garage/tests/s3')
-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/"); + } +} |