Skip to content

Commit

Permalink
version 0.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
stitam authored and cran-robot committed Jan 24, 2024
1 parent 92f8d25 commit 19caed0
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 98 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Description: Suite of tools for managing cached files, targeting
Provides utilities to manage cache directories, including targeting
files by path or by key; cached directories can be compressed and
uncompressed easily to save disk space.
Version: 0.5.3
Version: 0.5.4
Authors@R: c(person("Scott", "Chamberlain", role = "aut",
comment = c(ORCID="0000-0003-2542-2202")),
person("Tamás", "Stirling", role = c("ctb", "cre"),
Expand All @@ -23,10 +23,11 @@ RoxygenNote: 7.2.3
X-schema.org-applicationCategory: Data
X-schema.org-keywords: caching, data, files, xml, pdf
X-schema.org-isPartOf: https://ropensci.org
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2023-01-26 09:34:04 UTC; tamas
Packaged: 2024-01-23 09:10:25 UTC; tamas
Author: Scott Chamberlain [aut] (<https://orcid.org/0000-0003-2542-2202>),
Tamás Stirling [ctb, cre]
Maintainer: Tamás Stirling <[email protected]>
Repository: CRAN
Date/Publication: 2023-01-26 16:00:02 UTC
Date/Publication: 2024-01-23 09:40:06 UTC
18 changes: 9 additions & 9 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
551617189c0080188c416a474d6dd0fe *DESCRIPTION
c479246040e9d3e985c604ad89c9fdbc *DESCRIPTION
35bd8606c71dfbfad3ad27387e177ad4 *LICENSE
55e3517dd2332c0fb5592ca86f74e112 *NAMESPACE
3dceee2206b78feb2e1566940c60d357 *NEWS.md
790d96715022bd701cf1991d6d41fb27 *NEWS.md
093ac5dd5475d363669db3098a2d9b61 *R/details.R
314241f467e46bd99b404feb304f4742 *R/hoard-package.R
b90402d7312395ce623b618f1d03c304 *R/hoard_client.R
17abdfb6022ac7441935f0dc9f96cd0a *R/zzz.R
7f0d2904db6951443f9247374dd360c7 *README.md
e9dfc7af8424b2feee0b749f25e5232e *build/vignette.rds
35e8ca8f5a9e3ce2572118c365e386c2 *README.md
28ba4046c581212b890852d69ffb5af8 *build/vignette.rds
e7038584fc028220c4d4e02505170880 *inst/doc/hoardr_vignette.R
74d61fc8457e3bfc9f0baeb0f0f7190c *inst/doc/hoardr_vignette.Rmd
7b9c5a8f43f82643761b073e9b0f04ee *inst/doc/hoardr_vignette.html
b596d2c2c995e396115be49dde47d21b *inst/doc/hoardr_vignette.html
07f950c569b053595a2a03f56291afcb *man/hoard.Rd
fcf35f91e454e1cd172a08f1e22b0490 *man/hoardr-package.Rd
b09a16cf2c04000996dab1bbac0443ee *tests/test-all.R
42b93564de72215c55f2cf533234cf81 *tests/testthat/test-HoardClient.R
5b65b96d4b1a1831ad437eb14d46f25e *tests/testthat/test-hoard.R
d4cef468911db06b4915668d2e326f68 *tests/testthat/test-utils.R
d7ee8d2edb16213632bd2bdd68d98407 *tests/testthat.R
44251381b8287fbe26dfa2cce2457575 *tests/testthat/test-HoardClient.R
6d5db5bf6799e5dc5ab58b42f9caaf4f *tests/testthat/test-hoard.R
37226a08f90b714e363fece4b0545934 *tests/testthat/test-utils.R
74d61fc8457e3bfc9f0baeb0f0f7190c *vignettes/hoardr_vignette.Rmd
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
hoardr 0.5.4
============

### BUG FIXES

* `testthat::test_check()` failed when full path for cache dir was `tempdir()`.
Replaced `tempdir()` with a full path that works (#23).

hoardr 0.5.3
============

Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![cran
checks](https://badges.cranchecks.info/worst/hoardr.svg)](https://badges.cranchecks.info/worst/hoardr.svg)
[![R-check](https://github.com/ropensci/hoardr/workflows/R-check/badge.svg)](https://github.com/ropensci/hoardr/actions?query=workflow%3AR-check)
[![codecov.io](https://codecov.io/github/ropensci/hoardr/coverage.svg?branch=master)](https://codecov.io/github/ropensci/hoardr?branch=master)
[![codecov.io](https://codecov.io/github/ropensci/hoardr/coverage.svg?branch=master)](https://app.codecov.io/github/ropensci/hoardr?branch=master)
[![rstudio mirror
downloads](https://cranlogs.r-pkg.org/badges/hoardr)](https://cran.r-project.org/package=hoardr)
[![cran
Expand Down Expand Up @@ -54,7 +54,7 @@ set cache path

``` r
x$cache_path_set("foobar", type = 'tempdir')
#> [1] "/tmp/RtmpQCahl1/R/foobar"
#> [1] "/tmp/Rtmp4oqK58/R/foobar"
```

make the directory if doesn’t exist
Expand All @@ -73,15 +73,15 @@ list the files

``` r
x$list()
#> [1] "/tmp/RtmpQCahl1/R/foobar/foo.txt"
#> [1] "/tmp/Rtmp4oqK58/R/foobar/foo.txt"
```

details

``` r
x$details()
#> <cached files>
#> directory: /tmp/RtmpQCahl1/R/foobar
#> directory: /tmp/Rtmp4oqK58/R/foobar
#>
#> file: /foo.txt
#> size: 0 mb
Expand All @@ -95,10 +95,6 @@ x$list()
#> character(0)
```

## todo

see [issue 1](https://github.com/ropensci/hoardr/issues/1)

## Meta

- Please [report any issues or
Expand Down
Binary file modified build/vignette.rds
Binary file not shown.
26 changes: 10 additions & 16 deletions inst/doc/hoardr_vignette.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/test-all.R → tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
library("testthat")
library("hoardr")
test_check("hoardr")
74 changes: 35 additions & 39 deletions tests/testthat/test-HoardClient.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
context("HoardClient - when files don't exist")

test_that("HoardClient works", {
test_that("HoardClient works when files don't exist", {
aa <- HoardClient
expect_is(aa, "R6ClassGenerator")
expect_s3_class(aa, "R6ClassGenerator")

bb <- HoardClient$new()

expect_is(bb, "HoardClient")
expect_is(bb, "R6")
expect_s3_class(bb, "HoardClient")
expect_s3_class(bb, "R6")
expect_null(bb$path)
expect_null(bb$type)

Expand All @@ -17,13 +15,13 @@ test_that("HoardClient works", {

# test cache_path_get method
## before set
expect_is(bb$cache_path_get, "function")
expect_equal(class(bb$cache_path_get), "function")
expect_null(bb$cache_path_get())

# test cache_path_set method
expect_is(bb$cache_path_set, "function")
expect_equal(class(bb$cache_path_set), "function")
expect_equal(length(bb$cache_path_set()), 0)
expect_is(
expect_type(
bb$cache_path_set(path = "test123", type = 'tempdir'),
"character"
)
Expand All @@ -33,8 +31,8 @@ test_that("HoardClient works", {
)

# use full_path
expect_is(
bb$cache_path_set(full_path = tempdir()),
expect_type(
bb$cache_path_set(full_path = file.path(tempdir(), "foobar")),
'character'
)

Expand All @@ -45,80 +43,78 @@ test_that("HoardClient works", {

# test cache_path_get method
## after set
expect_is(bb$cache_path_get(), "character")
expect_type(bb$cache_path_get(), "character")

# test list method
expect_is(bb$list, "function")
expect_equal(class(bb$list), "function")
expect_equal(length(bb$list()), 0)

# test mkdir method
expect_is(bb$mkdir, "function")
expect_equal(class(bb$mkdir), "function")
expect_false(dir.exists(bb$cache_path_get()))
expect_true(bb$mkdir())
expect_true(dir.exists(bb$cache_path_get()))

# test delete method
expect_is(bb$delete, "function")
expect_equal(class(bb$delete), "function")
## no files input
expect_error(bb$delete(), "argument \"files\" is missing")

# test delete_all method
expect_is(bb$delete_all, "function")
expect_equal(class(bb$delete_all), "function")
## no files input
expect_message(bb$delete_all(), "no files found")
expect_null(suppressMessages(bb$delete_all()))

# test details method
expect_is(bb$details, "function")
expect_equal(class(bb$details), "function")
## no files in yet
deets1 <- bb$details()
expect_equal(length(deets1), 0)

# test key method
expect_is(bb$key, "function")
expect_equal(class(bb$key), "function")
## no x param passed
expect_error(bb$key(), "argument \"x\" is missing")
## no files in yet
expect_error(bb$key(x = "adfdf"), "file does not exist")

# test keys method
expect_is(bb$keys, "function")
expect_equal(class(bb$keys), "function")
## no files in yet, gives NULL
expect_null(bb$keys())

# test files method
expect_is(bb$files, "function")
expect_equal(class(bb$files), "function")
## no files in yet, gives NULL
expect_null(bb$files())

# test compress method
expect_is(bb$compress, "function")
expect_equal(class(bb$compress), "function")
## no files in yet, gives error
expect_error(bb$compress(), "no files to compress")

# test uncompress method
expect_is(bb$uncompress, "function")
expect_equal(class(bb$uncompress), "function")
## no files in yet, gives error
expect_message(bb$uncompress(), "no files to uncompress")

# test exists method
## add some files first
cat(1:10000L, file = file.path(bb$cache_path_get(), "bar1.txt"))
cat(1:10000L, file = file.path(bb$cache_path_get(), "bar2.txt"))
expect_is(bb$exists('bar1.txt'), "data.frame")
expect_s3_class(bb$exists('bar1.txt'), "data.frame")
expect_true(bb$exists('bar1.txt')$exists)
expect_false(bb$exists('asdfasdsdf')$exists)
## no files in yet, gives error
expect_error(bb$exists(), "argument \"files\" is missing")
})

context("HoardClient - when files exist")

test_that("HoardClient works", {
test_that("HoardClient works when files exist", {
cc <- HoardClient$new()

expect_is(cc, "HoardClient")
expect_is(cc, "R6")
expect_s3_class(cc, "HoardClient")
expect_s3_class(cc, "R6")

# set cache path
cc$cache_path_set(path = "test456", type = 'tempdir')
Expand All @@ -133,9 +129,9 @@ test_that("HoardClient works", {
cat(1:10000L, file = file.path(cc$cache_path_get(), "foo3.txt"))

# test list method
expect_is(cc$list, "function")
expect_equal(class(cc$list), "function")
expect_equal(length(cc$list()), 4)
expect_is(cc$list(), "character")
expect_type(cc$list(), "character")

# test delete method
expect_error(cc$delete(), "argument \"files\" is missing")
Expand All @@ -151,9 +147,9 @@ test_that("HoardClient works", {

# test details method
deets1 <- cc$details()
expect_is(deets1, "cache_info")
expect_equal(class(deets1), "cache_info")
expect_equal(length(deets1), 4)
expect_is(deets1[[1]], "list")
expect_type(deets1[[1]], "list")
expect_named(deets1[[1]], c('file', 'type', 'size'))
## print method print.cache_info
expect_output(print(deets1), "<cached files>")
Expand All @@ -162,22 +158,22 @@ test_that("HoardClient works", {
expect_output(print(deets1), "mb")

# test key method
expect_is(cc$key(x = cc$list()[1]), "character")
expect_type(cc$key(x = cc$list()[1]), "character")
expect_identical(cc$key(x = cc$list()[1]), cc$key(x = cc$list()[1]))

# test keys method
expect_is(cc$keys(), "character")
expect_type(cc$keys(), "character")
expect_equal(length(cc$keys()), 4)

# test files method
expect_is(cc$files(), "list")
expect_type(cc$files(), "list")
zz <- cc$files()[[1]]
expect_is(zz, "HoardFile")
expect_is(zz$exists, "function")
expect_s3_class(zz, "HoardFile")
expect_equal(class(zz$exists), "function")
expect_true(zz$exists())
expect_is(zz$path, "character")
expect_type(zz$path, "character")
expect_equal(zz$path, cc$list()[1])
expect_is(zz$print, "function")
expect_equal(class(zz$print), "function")
expect_output(zz$print(), "<hoard file>")
expect_output(zz$print(), "path:")

Expand Down
33 changes: 15 additions & 18 deletions tests/testthat/test-hoard.R
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
context("hoard")
test_that("hoard works", {
aa <- hoard()

expect_is(aa, "HoardClient")
expect_is(aa, "R6")
expect_is(aa$cache_path_get, "function")
expect_is(aa$cache_path_set, "function")
expect_is(aa$compress, "function")
expect_is(aa$uncompress, "function")
expect_is(aa$delete, "function")
expect_is(aa$delete_all, "function")
expect_is(aa$details, "function")
expect_is(aa$files, "function")
expect_is(aa$key, "function")
expect_is(aa$keys, "function")
expect_is(aa$list, "function")
expect_is(aa$mkdir, "function")
expect_s3_class(aa, "HoardClient")
expect_s3_class(aa, "R6")
expect_equal(class(aa$cache_path_get), "function")
expect_equal(class(aa$cache_path_set), "function")
expect_equal(class(aa$compress), "function")
expect_equal(class(aa$uncompress), "function")
expect_equal(class(aa$delete), "function")
expect_equal(class(aa$delete_all), "function")
expect_equal(class(aa$details), "function")
expect_equal(class(aa$files), "function")
expect_equal(class(aa$key), "function")
expect_equal(class(aa$keys), "function")
expect_equal(class(aa$list), "function")
expect_equal(class(aa$mkdir), "function")
expect_null(aa$path)
expect_null(aa$type)
})

context("hoard: multiple instances")
test_that("hoard works", {
test_that("hoard works with multiple instances", {
aa <- hoard()
bb <- hoard()

Expand All @@ -36,7 +34,6 @@ test_that("hoard works", {
expect_match(bb$cache_path_get(), 'helloworld')
})

context("hoard: fails well")
test_that("hoard fails well", {
expect_error(hoard(f = 5),
"unused argument")
Expand Down
8 changes: 3 additions & 5 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
context("util functions")

test_that("ct", {
expect_is(ct, "function")
expect_equal(class(ct), "function")
expect_equal(length(ct(list(NULL, 4))), 1)
})

test_that("assert_is", {
expect_is(assert_is, "function")
expect_equal(class(assert_is), "function")
expect_null(assert_is(TRUE, "logical"))
expect_error(assert_is(TRUE, "character"), "TRUE must be of class character")
})

test_that("assert_n", {
expect_is(assert_n, "function")
expect_equal(class(assert_n), "function")
expect_null(assert_n(letters, 26))
expect_error(assert_n(letters, 4), "letters must be length 4")
})

0 comments on commit 19caed0

Please sign in to comment.