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)
})

Try the DatabaseConnector package in your browser

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

DatabaseConnector documentation built on May 29, 2024, 6:14 a.m.