From dfb2adde60a3c7afbfbe7fee0658d76f3cb5303f Mon Sep 17 00:00:00 2001 From: Yohann Mansiaux Date: Wed, 12 Jun 2024 13:52:00 +0200 Subject: [PATCH] feat: Adding codecov_fun argument coherence checking in inflate() #256 --- R/inflate.R | 10 +++++++++- tests/testthat/test-inflate-part3.R | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/R/inflate.R b/R/inflate.R index 782a4ef..5aff45b 100644 --- a/R/inflate.R +++ b/R/inflate.R @@ -371,7 +371,15 @@ inflate <- function(pkg = ".", flat_file, ) if (codecov) { - if (!codecov_fun %in% c("package_coverage", "report")) { + codecov_fun <- try( + match.arg( + codecov_fun, + c("package_coverage", "report"), + several.ok = FALSE + ), + silent = TRUE + ) + if (inherits(codecov_fun, "try-error")) { cli::cli_abort("codecov_fun must be either 'package_coverage' or 'report'") } diff --git a/tests/testthat/test-inflate-part3.R b/tests/testthat/test-inflate-part3.R index 6a666fb..3b4123e 100644 --- a/tests/testthat/test-inflate-part3.R +++ b/tests/testthat/test-inflate-part3.R @@ -13,6 +13,7 @@ usethis::with_project(dummypackage, { open = FALSE, overwrite = TRUE ) + capture.output( inflate( pkg = dummypackage,