Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use skip_if_not() to assert 'rotor' availability #65

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 11 additions & 25 deletions tests/testthat/test_AppenderFileRotating.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,13 @@ teardown({
unlink(td, recursive = TRUE)
})


assert_supported_rotor_version <- function(){ # TODO: change to throwing an error once rotor 0.3.0 is on CRAN
if (packageVersion("rotor") < "0.3.0")
skip("rotor < 0.3.0 is no longer supported")
}



# AppenderFileRotating -----------------------------------------------------

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

assert_supported_rotor_version()
skip_if_not_installed("rotor", "0.3.0")

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

assert_supported_rotor_version()
skip_if_not_installed("rotor", "0.3.0")

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

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

assert_supported_rotor_version()
skip_if_not_installed("rotor", "0.3.0")

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

assert_supported_rotor_version()
skip_if_not_installed("rotor", "0.3.0")

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


test_that("AppenderFileRotatingDate: works with different backup_dir", {
if (!is_zipcmd_available())
skip("Test requires a workings system zip command")

assert_supported_rotor_version()
skip_if_not(is_zipcmd_available(), "Test requires a workings system zip command")
skip_if_not_installed("rotor", "0.3.0")

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


test_that("AppenderFileRotatingDate: `size` and `age` arguments work as expected", {
assert_supported_rotor_version()
skip_if_not_installed("rotor", "0.3.0")

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

test_that("AppenderFileRotatingTime: works as expected", {
if (!is_zipcmd_available())
skip("Test requires a workings system zip command")

assert_supported_rotor_version()
skip_if_not(is_zipcmd_available(), "Test requires a workings system zip command")
skip_if_not_installed("rotor", "0.3.0")

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


test_that("AppenderFileRotatingTime: works with different backup_dir", {
if (!is_zipcmd_available())
skip("Test requires a workings system zip command")

assert_supported_rotor_version()
skip_if_not(is_zipcmd_available(), "Test requires a workings system zip command")
skip_if_not_installed("rotor", "0.3.0")

tf <- file.path(td, "test.log")
bu_dir <- file.path(td, "backups")
Expand Down
4 changes: 1 addition & 3 deletions tests/testthat/test_print_Appender.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ context("print_Appender")


test_that("all Appenders print() without failure", {
if (!requireNamespace("rotor")){
skip("Required packages not installed")
}
skip_if_not_installed("rotor")

tf <- tempfile()
on.exit(unlink(tf))
Expand Down