tests/testthat/test-psid_unzip.R

test_that("psid_unzip() helps unzip and convert the data to .rda files", {
  # exdir <- tempdir()
  # indir <- system.file(package = "psidread","extdata") # Define the output directory
  #
  # # Package version
  # psid_unzip(indir = indir, exdir = exdir, zipped = TRUE, type = "package", filename = NA)
  # actual_output_pkg <- list.files(path = exdir, pattern = "^(fam|ind)[0-9]{4}(er)?\\.rda")
  # exp_output <- c("fam2013er.rda","fam2017er.rda","ind2021er.rda")
  # expect_equal(sum(1-exp_output %in% actual_output_pkg), 0)
  #
  # # Specific one file
  # psid_unzip(indir = indir, exdir = exdir, zipped = TRUE, type = "single", filename = "J327825.zip")
  # expect_equal("J327825.rda" %in% list.files(path = exdir, pattern = ".*\\.rda"),TRUE)

  # Check file test
  indir <- system.file(package = "psidread","extdata") # Define the output directory
  # Package version
  actual_output_pkg <- list.files(path = indir, pattern = "^(fam|ind)[0-9]{4}(er)?\\.rda")
  exp_output <- c("fam2013er.rda","fam2017er.rda","ind2021er.rda")
  expect_equal(sum(1-exp_output %in% actual_output_pkg), 0)
  # Specific one file
  expect_equal("J327825.rda" %in% list.files(path = indir, pattern = ".*\\.rda"),TRUE)
})

Try the psidread package in your browser

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

psidread documentation built on Aug. 8, 2025, 7:44 p.m.