Skip to content

Commit

Permalink
nocov directives on helper
Browse files Browse the repository at this point in the history
ref #556
  • Loading branch information
wibeasley committed Dec 5, 2024
1 parent 470c985 commit e664698
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions R/helpers-testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@ retrieve_credential_testing <- function(
if(Sys.getenv("redcapr_test_server") != "") {
Sys.getenv("redcapr_test_server")
} else {
# nocov start
message("The test server was not explicitly set, so defaulting to 'dev-2'.")
"dev-2"
# nocov end
}
checkmate::assert_character(server_instance , any.missing = FALSE, min.chars = 2, max.chars = 50)

# This line avoids a warning from the package check.
projects <- project_id <- instance <- tag <- NULL

if (!requireNamespace("yaml", quietly = TRUE)) {
# nocov start
stop(
"Package `yaml` must be installed to use this function.",
call. = FALSE
)
# nocov end
}
d_map <-
system.file("misc/project-redirection.yml", package = "REDCapR") |>
Expand All @@ -40,18 +44,20 @@ retrieve_credential_testing <- function(
dplyr::filter(tag == project_tag)

if (nrow(d_map) == 0L) {
stop("A credential mapping entry does not exist for the desired arguments.")
stop("A credential mapping entry does not exist for the desired arguments.") # nocov
}

path_credential <- system.file(d_map$credential_file, package = "REDCapR")
if (!base::file.exists(path_credential)) {
# nocov start
stop(
"The credential file `",
d_map$credential_file,
"` associated with the `",
server_instance,
"` does not exist on this machine."
)
# nocov end
}

retrieve_credential_local(
Expand All @@ -67,19 +73,23 @@ retrieve_plugins <- function(plugin_name) {
if(Sys.getenv("redcapr_test_server") != "") {
Sys.getenv("redcapr_test_server")
} else {
# nocov start
message("The test server was not explicitly set for plugins, so defaulting to 'dev-2'.")
"dev-2"
# nocov end
}
checkmate::assert_character(server_instance , any.missing = FALSE, min.chars = 2, max.chars = 50)

# This line avoids a warning from the package check.
plugins <- instance <- tag <- project_tag <- NULL

if (!requireNamespace("yaml", quietly = TRUE)) {
# nocov start
stop(
"Package `yaml` must be installed to use this function.",
call. = FALSE
)
# nocov end
}
d_map <-
system.file("misc/plugin-redirection.yml", package = "REDCapR") |>
Expand All @@ -98,7 +108,7 @@ retrieve_plugins <- function(plugin_name) {
dplyr::filter(tag == plugin_name)

if (nrow(d_map) == 0L) {
stop("A plugin mapping entry does not exist for the desired arguments.")
stop("A plugin mapping entry does not exist for the desired arguments.") # nocov
}

d_map |>
Expand Down

0 comments on commit e664698

Please sign in to comment.