From 9cad5cf0e1c03c81b6aabeb06a7ab38b24e32241 Mon Sep 17 00:00:00 2001 From: James McMahon Date: Mon, 14 Aug 2023 12:25:40 +0100 Subject: [PATCH 1/3] Add additional tests for `check_it_reference()` --- tests/testthat/test-get_it_extract_paths.R | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/testthat/test-get_it_extract_paths.R b/tests/testthat/test-get_it_extract_paths.R index baaad52a5..52f9e4181 100644 --- a/tests/testthat/test-get_it_extract_paths.R +++ b/tests/testthat/test-get_it_extract_paths.R @@ -1,3 +1,25 @@ +test_that("IT reference cleanup works", { + expect_equal(check_it_reference("SCTASK0439133"), "0439133") + expect_equal(check_it_reference("0439133"), "0439133") + + expect_error( + check_it_reference("123456789"), + "`it_reference` must be exactly 7 numbers\\." + ) + expect_error( + check_it_reference("1234567890"), + "`it_reference` must be exactly 7 numbers\\." + ) + expect_error( + check_it_reference("SCTASK123456789"), + "`it_reference` must be exactly 7 numbers\\." + ) + expect_error( + check_it_reference("ABCDEF123456789"), + "`it_reference` must be exactly 7 numbers\\." + ) +}) + skip_on_ci() test_that("IT extract file paths work", { From 6cce742e5d2f94e4f791e4d6d461571d4a5f8b14 Mon Sep 17 00:00:00 2001 From: James McMahon Date: Mon, 14 Aug 2023 12:26:23 +0100 Subject: [PATCH 2/3] Make the check on the IT reference stricter --- R/get_it_extract_paths.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/get_it_extract_paths.R b/R/get_it_extract_paths.R index 2c587e93b..3c4dc54c3 100644 --- a/R/get_it_extract_paths.R +++ b/R/get_it_extract_paths.R @@ -107,7 +107,7 @@ check_it_reference <- function(it_reference) { it_reference <- stringr::str_sub(it_reference, start = 7L, end = 14L) } - if (stringr::str_detect(it_reference, "[0-9]{7}", negate = TRUE)) { + if (stringr::str_detect(it_reference, "^[0-9]{7}$", negate = TRUE)) { cli::cli_abort( c("x" = "{.arg it_reference} must be exactly 7 numbers."), call = rlang::caller_env() From 4014254231dbade4203d14b1a8b6f8b1bf673444 Mon Sep 17 00:00:00 2001 From: Jennit07 Date: Mon, 25 Sep 2023 07:48:46 +0000 Subject: [PATCH 3/3] Update documentation --- man/read_file.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/read_file.Rd b/man/read_file.Rd index b8231218f..1ef351342 100644 --- a/man/read_file.Rd +++ b/man/read_file.Rd @@ -14,7 +14,7 @@ read_file(path, col_select = NULL, as_data_frame = TRUE, ...) \link[tidyselect:eval_select]{tidy selection specification} of columns, as used in \code{dplyr::select()}.} -\item{as_data_frame}{Should the function return a \code{data.frame} (default) or +\item{as_data_frame}{Should the function return a \code{tibble} (default) or an Arrow \link[arrow]{Table}?} \item{...}{Addition arguments passed to the relevant function.}