tests/testthat/test-valid_file_info.R

test_that("valid_file_info returns file metadata", {
  path <- tempfile()
  writeLines("Test content", path)
  on.exit(unlink(path), add = TRUE)

  result <- valid_file_info(path)

  expect_s3_class(result, "data.frame")
  expect_equal(nrow(result), 1L)
  expect_gt(result$size, 0)
  expect_false(result$isdir)
  expect_equal(result, file.info(path))
})


test_that("valid_file_info rejects nonexistent files", {
  path <- tempfile()

  expect_error(
    valid_file_info(path),
    "is not a file",
    fixed = TRUE
  )
})


test_that("valid_file_info rejects directories", {
  expect_error(
    valid_file_info(tempdir()),
    "is not a file",
    fixed = TRUE
  )
})


test_that("valid_file_info rejects missing file paths", {
  expect_error(
    valid_file_info(NA_character_),
    "is not a file",
    fixed = TRUE
  )
})


test_that("valid_file_info rejects multiple file paths", {
  paths <- c(tempfile(), tempfile())
  file.create(paths)
  on.exit(unlink(paths), add = TRUE)

  expect_error(
    valid_file_info(paths),
    "is not a file",
    fixed = TRUE
  )
})

Try the retroharmonize package in your browser

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

retroharmonize documentation built on Nov. 29, 2026, 5:06 p.m.