Skip to content

Commit

Permalink
chore: update object_store unit tests and s3 endpoint docs (#3345)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorseraq authored Oct 18, 2023
1 parent bf40d14 commit c52061a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ impl S3Builder {
/// Endpoint must be full uri, e.g.
///
/// - AWS S3: `https://s3.amazonaws.com` or `https://s3.{region}.amazonaws.com`
/// - Cloudflare R2: `https://<ACCOUNT_ID>.r2.cloudflarestorage.com`
/// - Aliyun OSS: `https://{region}.aliyuncs.com`
/// - Tencent COS: `https://cos.{region}.myqcloud.com`
/// - Minio: `http://127.0.0.1:9000`
Expand Down
42 changes: 39 additions & 3 deletions integrations/object_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,22 @@ mod tests {
let path: Path = "data/test.txt".try_into().unwrap();

let bytes = Bytes::from_static(b"hello, world!");
object_store.put(&path, bytes).await.unwrap();
object_store.put(&path, bytes.clone()).await.unwrap();

let meta = object_store.head(&path).await.unwrap();

assert_eq!(meta.size, 13)
assert_eq!(meta.size, 13);

assert_eq!(
object_store
.get(&path)
.await
.unwrap()
.bytes()
.await
.unwrap(),
bytes
);
}

#[tokio::test]
Expand All @@ -327,8 +338,33 @@ mod tests {
.iter()
.map(|x| x.as_ref().unwrap().location.as_ref())
.collect::<Vec<_>>();

let expected_files = vec![
(
"data/nested/test.txt",
Bytes::from_static(b"hello, world! I am nested."),
),
("data/test.txt", Bytes::from_static(b"hello, world!")),
];

let expected_locations = expected_files.iter().map(|x| x.0).collect::<Vec<&str>>();

locations.sort();
assert_eq!(locations, &["data/nested/test.txt", "data/test.txt"]);
assert_eq!(locations, expected_locations);

for (location, bytes) in expected_files {
let path: Path = location.try_into().unwrap();
assert_eq!(
object_store
.get(&path)
.await
.unwrap()
.bytes()
.await
.unwrap(),
bytes
);
}
}

#[tokio::test]
Expand Down

0 comments on commit c52061a

Please sign in to comment.