Skip to content

Commit

Permalink
Test aws_list_etags()
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Nov 9, 2023
1 parent 51e34a2 commit f89d25b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/utils_aws.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ aws_s3_list_etags <- function(
)
}
pages <- paws.common::paginate(
Operation = do.call(what = client$list_objects_v2, args = args)
Operation = do.call(what = client$list_objects_v2, args = args),
PageSize = page_size
)
out <- list()
for (page in pages) {
Expand Down
28 changes: 28 additions & 0 deletions tests/aws/test-utils_aws.R
Original file line number Diff line number Diff line change
Expand Up @@ -642,3 +642,31 @@ tar_test("graceful error on multipart upload", {
class = "tar_condition_file"
)
})

tar_test("aws_s3_list_etags()", {
bucket <- random_bucket_name()
paws.storage::s3()$create_bucket(Bucket = bucket)
on.exit(aws_s3_delete_bucket(bucket))
expect_equal(
aws_s3_list_etags(prefix = "/", bucket = bucket),
list()
)
for (key in c("w", "x", "y", "z")) {
paws.storage::s3()$put_object(
Body = charToRaw(key),
Key = key,
Bucket = bucket
)
}
out <- aws_s3_list_etags(prefix = "", bucket = bucket)
out2 <- aws_s3_list_etags(prefix = "", bucket = bucket, page_size = 2L)
expect_equal(out, out2)
expect_equal(length(out), 4L)
expect_equal(sort(names(out)), sort(c("w", "x", "y", "z")))
for (etag in out) {
expect_true(is.character(etag))
expect_true(!anyNA(etag))
expect_equal(length(etag), 1L)
expect_gt(nchar(etag), 10L)
}
})

0 comments on commit f89d25b

Please sign in to comment.