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 Nov. 18, 2021, 5:08 p.m.