inst/tinytest/test_file_modified_last.R

if (interactive()) {
  pkgload::load_all()
  library("tinytest")
}


dir.create(file.path(tempdir(), "new"))
touch(file.path(tempdir(), "file1.txt"))
Sys.sleep(2)
touch(file.path(tempdir(), "file2.txt"))
Sys.sleep(2)
touch(file.path(tempdir(), "new", "file3.txt"))
expectation <- "file2.txt"
found <- file_modified_last(path = tempdir(), pattern = "file.\\.txt$")
result <- basename(found)
expect_identical(expectation, result)
expectation <- "file3.txt"
found <- file_modified_last(
  path = tempdir(), pattern = "file.\\.txt$",
  recursive = TRUE
)
result <- basename(found)
expect_identical(expectation, result)

Try the fritools2 package in your browser

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

fritools2 documentation built on July 9, 2023, 7:07 p.m.