tests/testthat/test-most_recent_file.R

context("Most Recent File")

test_that(
    desc = "Wrong path returns error",
    code = expect_error(object = most_recent_file(path = "wrong path"),
                        regexp = "Assertion on \\'path\\' failed")
)

test_that(desc = "vector is of correct length",
          code = expect_length(object = most_recent_file(
              path = Sys.getenv("R_DOC_DIR"),
              n = 1
          ),
          n = 1))

test_that(desc = "returns path",
          code = expect_true(file.exists(
              most_recent_file(
                  path = Sys.getenv("R_DOC_DIR"),
                  full.names = TRUE,
                  n = 1
              )
          )))
konradedgar/FileFinder documentation built on May 3, 2019, 1:34 p.m.