Skip to content

Commit

Permalink
checks
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Aug 25, 2023
1 parent 517a997 commit d8f5528
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 21 deletions.
1 change: 0 additions & 1 deletion R/utils_retry.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ retry_until_success <- function(
start = start
)
}
out
}

retry_attempt_success <- function(fun, args, envir, verbose, classes_retry) {
Expand Down
17 changes: 10 additions & 7 deletions tests/testthat/test-tar_resources.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ tar_test("populated resources", {
skip_on_os("windows")
skip_if_not_installed("paws.storage")
out <- tar_resources(
aws = resources_aws_init(),
gcp = resources_gcp_init(),
aws = resources_aws_init(prefix = "x"),
gcp = resources_gcp_init(prefix = "x"),
clustermq = resources_clustermq_init(
template = list(a = 1, n_cores = 123)
)
Expand All @@ -24,11 +24,14 @@ tar_test("default resource args", {
skip_cran()
skip_on_os("windows")
skip_if_not_installed("paws.storage")
tar_option_set(
resources = tar_resources(
aws = tar_resources_aws(bucket = "abc"),
fst = tar_resources_fst(compress = 10L)
)
suppressWarnings(
tar_option_set(
resources = tar_resources(
aws = tar_resources_aws(bucket = "abc"),
fst = tar_resources_fst(compress = 10L)
)
),
classes = "tar_condition_deprecate"
)
target <- tar_target(
x,
Expand Down
29 changes: 21 additions & 8 deletions tests/testthat/test-tar_resources_aws.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ tar_test("tar_resources_aws()", {
skip_cran()
skip_on_os("windows")
skip_if_not_installed("paws.storage")
out <- tar_resources_aws(bucket = "bucket123")
out <- tar_resources_aws(bucket = "bucket123", prefix = "x")
expect_equal(out$bucket, "bucket123")
expect_null(out$region)
expect_silent(resources_validate(out))
Expand All @@ -12,7 +12,11 @@ tar_test("tar_resources_aws() with region", {
skip_cran()
skip_on_os("windows")
skip_if_not_installed("paws.storage")
out <- tar_resources_aws(bucket = "bucket123", region = "us-east-1")
out <- tar_resources_aws(
bucket = "bucket123",
region = "us-east-1",
prefix = "x"
)
expect_equal(out$region, "us-east-1")
expect_silent(resources_validate(out))
})
Expand All @@ -21,7 +25,11 @@ tar_test("tar_resources_aws() with part_size", {
skip_cran()
skip_on_os("windows")
skip_if_not_installed("paws.storage")
out <- tar_resources_aws(bucket = "bucket123", part_size = 1e8)
out <- tar_resources_aws(
bucket = "bucket123",
part_size = 1e8,
prefix = "x"
)
expect_equal(out$part_size, 1e8)
expect_silent(resources_validate(out))
})
Expand All @@ -33,7 +41,8 @@ tar_test("tar_resources_aws() default bucket", {
tar_option_set(
resources = tar_resources(
aws = tar_resources_aws(
bucket = "bucket123"
bucket = "bucket123",
prefix = "x"
)
)
)
Expand Down Expand Up @@ -64,7 +73,8 @@ tar_test("tar_resources_aws() default part_size", {
tar_option_set(
resources = tar_resources(
aws = tar_resources_aws(
part_size = 1e2
part_size = 1e2,
prefix = "x"
)
)
)
Expand All @@ -79,7 +89,8 @@ tar_test("tar_resources_aws() default region", {
tar_option_set(
resources = tar_resources(
aws = tar_resources_aws(
region = "the_moon"
region = "the_moon",
prefix = "x"
)
)
)
Expand All @@ -94,7 +105,8 @@ tar_test("tar_resources_aws() default endpoint", {
tar_option_set(
resources = tar_resources(
aws = tar_resources_aws(
endpoint = "google"
endpoint = "google",
prefix = "x"
)
)
)
Expand All @@ -109,7 +121,8 @@ tar_test("tar_resources_aws() default SSECustomerKey", {
tar_option_set(
resources = tar_resources(
aws = tar_resources_aws(
SSECustomerKey = "x"
SSECustomerKey = "x",
prefix = "x"
)
)
)
Expand Down
11 changes: 7 additions & 4 deletions tests/testthat/test-tar_resources_gcp.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tar_test("tar_resources_gcp()", {
out <- tar_resources_gcp(bucket = "bucket123")
out <- tar_resources_gcp(bucket = "bucket123", prefix = "x")
expect_equal(out$bucket, "bucket123")
expect_null(out$region)
expect_silent(resources_validate(out))
Expand All @@ -15,7 +15,8 @@ tar_test("tar_resources_gcp() default bucket", {
tar_option_set(
resources = tar_resources(
gcp = tar_resources_gcp(
bucket = "non_default"
bucket = "non_default",
prefix = "x"
)
)
)
Expand All @@ -39,7 +40,8 @@ tar_test("tar_resources_gcp() default predefined_acl", {
tar_option_set(
resources = tar_resources(
gcp = tar_resources_gcp(
predefined_acl = "non_default"
predefined_acl = "non_default",
prefix = "x"
)
)
)
Expand All @@ -51,7 +53,8 @@ tar_test("tar_resources_gcp() default predefined_acl", {
tar_option_set(
resources = tar_resources(
gcp = tar_resources_gcp(
verbose = TRUE
verbose = TRUE,
prefix = "x"
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-utils_assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ tar_test("tar_assert_resources()", {
tar_assert_resources(list(aws = 1)),
class = "tar_condition_deprecate"
)
aws <- tar_resources_aws(bucket = "bucket")
aws <- tar_resources_aws(bucket = "bucket", prefix = "x")
expect_silent(tar_assert_resources(tar_resources(aws = aws)))
})

Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-utils_retry.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ tar_test("retry_until_true() max_tries", {
expect_equal(envir$count, 5L)
})

tar_test("retry_until_success() success", {
skip_on_cran()
out <- retry_until_success(
fun = function() {
"done"
}
)
expect_equal(out, "done")
})

tar_test("retry_until_success() uncaught class", {
skip_on_cran()
tmp <- tempfile()
Expand Down

0 comments on commit d8f5528

Please sign in to comment.