tests/testthat/test-compression.R

library(testthat)

test_that("Create zip file", {

  # Create temp file to zip:
  fileToZip <- tempfile()
  zipFile <- tempfile()
  x <- data.frame(a = runif(100), b = sample(letters, 100, replace = TRUE))
  write.csv(x, fileToZip)

  # Zip:
  createZipFile(zipFile = zipFile, files = fileToZip)

  # Check if file is created and smaller than uncompressed file:
  expect_true(file.exists(zipFile))
  expect_lt(file.info(zipFile)$size, file.info(fileToZip)$size)

  # Cleanup
  unlink(fileToZip)
  unlink(zipFile)
})
OHDSI/DatabaseConnector documentation built on Jan. 31, 2024, 7:28 p.m.