Skip to content

Commit 9e3e5e0

Browse files
Use skip_if_not() to assert 'rotor' availability
The current version doesn't skip if 'rotor' is simply not installed; this will fix that
1 parent cd21d69 commit 9e3e5e0

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

tests/testthat/test_AppenderFileRotating.R

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,13 @@ teardown({
1111
unlink(td, recursive = TRUE)
1212
})
1313

14-
15-
assert_supported_rotor_version <- function(){ # TODO: change to throwing an error once rotor 0.3.0 is on CRAN
16-
if (packageVersion("rotor") < "0.3.0")
17-
skip("rotor < 0.3.0 is no longer supported")
18-
}
19-
20-
21-
2214
# AppenderFileRotating -----------------------------------------------------
2315

2416
test_that("AppenderFileRotating: works as expected", {
2517
if (!is_zipcmd_available())
2618
skip("Test requires a workings system zip command")
2719

28-
assert_supported_rotor_version()
20+
skip_if_not_installed("rotor", "0.3.0")
2921

3022
tf <- file.path(td, "test.log")
3123
app <- AppenderFileRotating$new(file = tf, size = "1tb")
@@ -80,7 +72,7 @@ test_that("AppenderFileRotating: works with different backup_dir", {
8072
if (!is_zipcmd_available())
8173
skip("Test requires a workings system zip command")
8274

83-
assert_supported_rotor_version()
75+
skip_if_not_installed("rotor", "0.3.0")
8476

8577
tf <- file.path(td, "test.log")
8678
bu_dir <- file.path(td, "backups")
@@ -136,7 +128,7 @@ test_that("AppenderFileRotating: works with different backup_dir", {
136128

137129
test_that("AppenderFileRotating: `size` argument works as expected", {
138130

139-
assert_supported_rotor_version()
131+
skip_if_not_installed("rotor", "0.3.0")
140132

141133
#setup
142134
tf <- file.path(td, "test.log")
@@ -167,7 +159,7 @@ test_that("AppenderFileRotatingDate: works as expected", {
167159
if (!is_zipcmd_available())
168160
skip("Test requires a workings system zip command")
169161

170-
assert_supported_rotor_version()
162+
skip_if_not_installed("rotor", "0.3.0")
171163

172164
tf <- file.path(td, "test.log")
173165
app <- AppenderFileRotatingDate$new(file = tf, size = "1tb")
@@ -226,10 +218,8 @@ test_that("AppenderFileRotatingDate: works as expected", {
226218

227219

228220
test_that("AppenderFileRotatingDate: works with different backup_dir", {
229-
if (!is_zipcmd_available())
230-
skip("Test requires a workings system zip command")
231-
232-
assert_supported_rotor_version()
221+
skip_if_not(is_zipcmd_available(), "Test requires a workings system zip command")
222+
skip_if_not_installed("rotor", "0.3.0")
233223

234224
tf <- file.path(td, "test.log")
235225
bu_dir <- file.path(td, "backups")
@@ -273,7 +263,7 @@ test_that("AppenderFileRotatingDate: works with different backup_dir", {
273263

274264

275265
test_that("AppenderFileRotatingDate: `size` and `age` arguments work as expected", {
276-
assert_supported_rotor_version()
266+
skip_if_not_installed("rotor", "0.3.0")
277267

278268
#setup
279269
tf <- file.path(td, "test.log")
@@ -309,10 +299,8 @@ test_that("AppenderFileRotatingDate: `size` and `age` arguments work as expected
309299
# AppenderFileRotatingTime ----------------------------------------------------
310300

311301
test_that("AppenderFileRotatingTime: works as expected", {
312-
if (!is_zipcmd_available())
313-
skip("Test requires a workings system zip command")
314-
315-
assert_supported_rotor_version()
302+
skip_if_not(is_zipcmd_available(), "Test requires a workings system zip command")
303+
skip_if_not_installed("rotor", "0.3.0")
316304

317305
tf <- file.path(td, "test.log")
318306
app <- AppenderFileRotatingTime$new(file = tf)
@@ -357,10 +345,8 @@ test_that("AppenderFileRotatingTime: works as expected", {
357345

358346

359347
test_that("AppenderFileRotatingTime: works with different backup_dir", {
360-
if (!is_zipcmd_available())
361-
skip("Test requires a workings system zip command")
362-
363-
assert_supported_rotor_version()
348+
skip_if_not(is_zipcmd_available(), "Test requires a workings system zip command")
349+
skip_if_not_installed("rotor", "0.3.0")
364350

365351
tf <- file.path(td, "test.log")
366352
bu_dir <- file.path(td, "backups")

0 commit comments

Comments
 (0)