Skip to content

Commit

Permalink
tests should check suggested packages are available
Browse files Browse the repository at this point in the history
*before* running!
  • Loading branch information
cboettig committed Aug 20, 2018
1 parent 9f3a5e1 commit 00e7569
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 32 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: arkdb
Version: 0.0.1
Version: 0.0.2
Title: Archive and Unarchive Databases Using Flat Files
Description: Flat text files provide a more robust, compressible,
and portable way to store tables. This package provides convenient
Description: Flat text files provide a robust, compressible, and portable
way to store tables from databases. This package provides convenient
functions for exporting tables from relational database connections
into compressed text files and streaming those text files back into
a database without requiring the whole table to fit in working memory.
Expand Down
8 changes: 6 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# arkdb 0.0.1
# arkdb 0.0.2

* Ensure the suggested dependency MonetDBLite is available before running unit test using it.

# arkdb 0.0.1 2018-08-20

* overwrite existing tables of same name (with warning and
interactive proceed) in both DB and text-files to avoid
appending.

# arkdb 0.0.0.9000
# arkdb 0.0.0.9000 2018-08-11

* Added a `NEWS.md` file to track changes to the package.
* Log messages improved as suggested by @richfitz
Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ output: github_document
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/arkdb)](https://cran.r-project.org/package=arkdb)
[![](https://badges.ropensci.org/224_status.svg)](https://github.com/ropensci/onboarding/issues/224)
[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1343943.svg)](https://doi.org/10.5281/zenodo.1343943)

<!-- README.md is generated from README.Rmd. Please edit that file -->

Expand Down
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ status](https://ci.appveyor.com/api/projects/status/28rxw294yfktiebj?svg=true)](
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/arkdb)](https://cran.r-project.org/package=arkdb)
[![](https://badges.ropensci.org/224_status.svg)](https://github.com/ropensci/onboarding/issues/224)
[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1343943.svg)](https://doi.org/10.5281/zenodo.1343943)

<!-- README.md is generated from README.Rmd. Please edit that file -->

Expand Down Expand Up @@ -57,7 +58,7 @@ Consider the `nycflights` database in SQLite:
``` r
tmp <- tempdir() # Or can be your working directory, "."
db <- dbplyr::nycflights13_sqlite(tmp)
#> Caching nycflights db at /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T//RtmpjCDDVg/nycflights13.sqlite
#> Caching nycflights db at /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T//RtmpvsQbO6/nycflights13.sqlite
#> Creating table: airlines
#> Creating table: airports
#> Creating table: flights
Expand All @@ -71,15 +72,15 @@ Create an archive of the database:
dir <- fs::dir_create(fs::path(tmp, "nycflights"))
ark(db, dir, lines = 50000)
#> Exporting airlines in 50000 line chunks:
#> ...Done! (in 0.009561777 secs)
#> ...Done! (in 0.008452892 secs)
#> Exporting airports in 50000 line chunks:
#> ...Done! (in 0.035254 secs)
#> ...Done! (in 0.02827597 secs)
#> Exporting flights in 50000 line chunks:
#> ...Done! (in 15.58381 secs)
#> ...Done! (in 15.24916 secs)
#> Exporting planes in 50000 line chunks:
#> ...Done! (in 0.04551506 secs)
#> ...Done! (in 0.05896616 secs)
#> Exporting weather in 50000 line chunks:
#> ...Done! (in 1.018439 secs)
#> ...Done! (in 1.423234 secs)
```

## Unarchive
Expand All @@ -92,19 +93,19 @@ files <- fs::dir_ls(dir)
new_db <- src_sqlite(fs::path(tmp, "local.sqlite"), create=TRUE)

unark(files, new_db, lines = 50000)
#> Importing /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpjCDDVg/nycflights/airlines.tsv.bz2 in 50000 line chunks:
#> ...Done! (in 0.03247809 secs)
#> Importing /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpjCDDVg/nycflights/airports.tsv.bz2 in 50000 line chunks:
#> ...Done! (in 0.04669309 secs)
#> Importing /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpjCDDVg/nycflights/flights.tsv.bz2 in 50000 line chunks:
#> ...Done! (in 11.08787 secs)
#> Importing /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpjCDDVg/nycflights/planes.tsv.bz2 in 50000 line chunks:
#> ...Done! (in 0.05716991 secs)
#> Importing /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpjCDDVg/nycflights/weather.tsv.bz2 in 50000 line chunks:
#> ...Done! (in 0.607512 secs)
#> Importing /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpvsQbO6/nycflights/airlines.tsv.bz2 in 50000 line chunks:
#> ...Done! (in 0.0220139 secs)
#> Importing /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpvsQbO6/nycflights/airports.tsv.bz2 in 50000 line chunks:
#> ...Done! (in 0.06350207 secs)
#> Importing /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpvsQbO6/nycflights/flights.tsv.bz2 in 50000 line chunks:
#> ...Done! (in 18.38258 secs)
#> Importing /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpvsQbO6/nycflights/planes.tsv.bz2 in 50000 line chunks:
#> ...Done! (in 0.1244881 secs)
#> Importing /var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpvsQbO6/nycflights/weather.tsv.bz2 in 50000 line chunks:
#> ...Done! (in 0.698673 secs)

new_db
#> src: sqlite 3.22.0 [/var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpjCDDVg/local.sqlite]
#> src: sqlite 3.22.0 [/var/folders/y8/0wn724zs10jd79_srhxvy49r0000gn/T/RtmpvsQbO6/local.sqlite]
#> tbls: airlines, airports, flights, planes, weather
```

Expand Down
15 changes: 11 additions & 4 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
],
"@type": "SoftwareSourceCode",
"identifier": "arkdb",
"description": "Flat text files provide a more robust, compressible,\n and portable way to store tables. This package provides convenient\n functions for exporting tables from relational database connections\n into compressed text files and streaming those text files back into\n a database without requiring the whole table to fit in working memory.",
"description": "Flat text files provide a robust, compressible, and portable\n way to store tables from databases. This package provides convenient\n functions for exporting tables from relational database connections\n into compressed text files and streaming those text files back into\n a database without requiring the whole table to fit in working memory.",
"name": "arkdb: Archive and Unarchive Databases Using Flat Files",
"codeRepository": "https://github.com/ropensci/arkdb",
"issueTracker": "https://github.com/ropensci/arkdb/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.0.1",
"version": "0.0.2",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -237,7 +237,7 @@
],
"releaseNotes": "https://github.com/ropensci/arkdb/blob/master/NEWS.md",
"readme": "https://github.com/ropensci/arkdb/blob/master/README.md",
"fileSize": "16.474KB",
"fileSize": "16.632KB",
"contIntegration": [
"https://travis-ci.org/cboettig/arkdb",
"https://codecov.io/github/cboettig/arkdb?branch=master",
Expand All @@ -250,5 +250,12 @@
"rstats",
"dbi"
],
"developmentStatus": "https://www.tidyverse.org/lifecycle/#stable"
"developmentStatus": "https://www.tidyverse.org/lifecycle/#stable",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"relatedLink": "https://CRAN.R-project.org/package=arkdb"
}
7 changes: 3 additions & 4 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Dear CRAN maintainers,

We are pleased to submit the initial release of arkdb for CRAN.
This submission ensures that vignettes, tests, and examples only
write to temporary directory, and directory must always be specified
explicitly by the user.
This release patches the issue in which a unit-test attempted to use a Suggested
package without first checking that said package was installed. This also corrects
a grammatical error in the package DESCRIPTION.


## Test environments
Expand Down
20 changes: 18 additions & 2 deletions tests/testthat/test-arkdb.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ new_db <- dplyr::src_sqlite(fs::path(tmp, "local.sqlite"), create = TRUE)
testthat::context("basic")
testthat::test_that("we can ark and unark a db", {

skip_if_not_installed("dplyr")
skip_if_not_installed("nycflights13")
skip_if_not_installed("readr")

ark(db, dir, lines = 50000, overwrite = TRUE)


Expand Down Expand Up @@ -47,8 +51,10 @@ testthat::test_that("we can ark and unark a db", {
testthat::context("plain-txt")

testthat::test_that("we can ark and unark a db in plain text", {
#db <- dbplyr::nycflights13_sqlite(tmp)
#dir <- fs::dir_create(fs::path(tmp, "nycflights"))

skip_if_not_installed("dplyr")
skip_if_not_installed("nycflights13")
skip_if_not_installed("readr")

ark(db, dir, lines = 50000, compress = "none", overwrite = TRUE)

Expand Down Expand Up @@ -81,6 +87,10 @@ testthat::context("alternate method")

testthat::test_that("alternate method for ark", {

skip_if_not_installed("dplyr")
skip_if_not_installed("nycflights13")
skip_if_not_installed("readr")

testthat::expect_warning(
ark(db, dir, lines = 50000, method = "window", overwrite = TRUE),
"overwriting")
Expand Down Expand Up @@ -111,6 +121,12 @@ testthat::test_that("alternate method for ark", {
testthat::context("MonetDB")
testthat::test_that("try with MonetDB & alternate method", {

skip_if_not_installed("MonetDBLite")
skip_if_not_installed("dplyr")
skip_if_not_installed("fs")
skip_if_not_installed("nycflights13")
skip_if_not_installed("readr")

## SETUP, with text files. (Could skip as these now exist from above tests)
data <- list(airlines = nycflights13::airlines,
airports = nycflights13::airports,
Expand Down

0 comments on commit 00e7569

Please sign in to comment.