tests/testthat/test_findfiles.R

root <- "Test_files"
dir.create(root)
file.extensions <- c("csv", "xls", "xlsx")
paths <- c()

q <- 10

for (ext in file.extensions){
  dir.create(file.path(root, ext))
  for (i in seq_len(q)){
    file <- glue::glue("Test {i}.{ext}")
    fp <- file.path("Test_files", ext, file)

    readr::write_excel_csv(data.frame(), fp)
  }
}

.files <- find_files("Test_files", file.extensions)

unlink("Test_files",recursive = TRUE)

expect_true(length(.files) == 30)

.classes <- sapply(.files, class)
expect_true(
  all(.classes %in% c("csv_path", "xls_path", "xlsx_path"))
)

Try the deident package in your browser

Any scripts or data that you put into this service are public.

deident documentation built on April 3, 2025, 6:14 p.m.