Skip to content

Commit

Permalink
[R-package] switch to SummaryReporter, remove context(), other testth…
Browse files Browse the repository at this point in the history
…at changes (#232)
  • Loading branch information
jameslamb authored Jan 28, 2025
1 parent 8cb4ae8 commit ffa29b0
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 34 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
*-Ex.R

# Output files from R CMD build
/*.tar.gz

# Output files from R CMD check
/*.Rcheck/
*.tar.gz
*.Rcheck/

# RStudio files
*.Rproj
Expand Down
15 changes: 7 additions & 8 deletions r-pkg/tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Note that you would never run this file directly. This is used by tools::testInstallPackages()
# and other packages like covr.

# This line ensures that R CMD check can run tests.
# See https://github.com/hadley/testthat/issues/144
Sys.setenv("R_TESTS" = "")

library(testthat)
library(uptasticsearch)

testthat::test_check('uptasticsearch')
testthat::test_check(
package = "uptasticsearch"
, stop_on_failure = TRUE
, stop_on_warning = FALSE
, reporter = testthat::SummaryReporter$new()
)
3 changes: 0 additions & 3 deletions r-pkg/tests/testthat/test-chomp_aggs.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ if (!identical(loggerOptions, list())){
}
futile.logger::flog.threshold(0)

context("chomp_aggs")

# Works with 1 variable from an R string
test_that(
"chomp_aggs should work from an R string with one grouping variable", {
Expand Down Expand Up @@ -609,4 +607,3 @@ test_that("chomp_aggs should work for an empty terms result", {

##### TEST TEAR DOWN #####
futile.logger::flog.threshold(origLogThreshold)
rm(list = ls())
3 changes: 0 additions & 3 deletions r-pkg/tests/testthat/test-chomp_hits.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ if (!identical(loggerOptions, list())){
}
futile.logger::flog.threshold(0)

context("chomp_hits")

# This is effectively a test of running elastic::Search(raw = TRUE) and passing it through chomp_hits()
test_that("chomp_hits should work from a one-element character vector",
{jsonString <- '{"took": 54, "timed_out": false, "_shards": {"total": 16,"successful": 16, "failed": 0},
Expand Down Expand Up @@ -127,4 +125,3 @@ test_that("chomp_hits should warn and delete if the resulting data is nested wit

##### TEST TEAR DOWN #####
futile.logger::flog.threshold(origLogThreshold)
rm(list = ls())
3 changes: 0 additions & 3 deletions r-pkg/tests/testthat/test-es_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ if (!identical(loggerOptions, list())){
}
futile.logger::flog.threshold(0)

context("es_search")

# Should reject NULL index
test_that("es_search should reject NULL index", {
expect_error({
Expand Down Expand Up @@ -130,4 +128,3 @@ test_that(".major_version should correctly parse semver version strings", {

##### TEST TEAR DOWN #####
futile.logger::flog.threshold(origLogThreshold)
rm(list = ls())
3 changes: 0 additions & 3 deletions r-pkg/tests/testthat/test-get_fields.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("get_fields")

# Configure logger (suppress all logs in testing)
loggerOptions <- futile.logger::logger.options()
if (!identical(loggerOptions, list())){
Expand Down Expand Up @@ -115,4 +113,3 @@ futile.logger::flog.threshold(0)

##### TEST TEAR DOWN #####
futile.logger::flog.threshold(origLogThreshold)
rm(list = ls())
3 changes: 0 additions & 3 deletions r-pkg/tests/testthat/test-integration.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Elasticsearch integration tests")

# tests in this file are run automatically in CI and require
# an actual Elasticsearch cluster to be up and running. For details,
# see: https://github.com/uptake/uptasticsearch/blob/main/.github/workflows/ci.yml
Expand Down Expand Up @@ -476,4 +474,3 @@ futile.logger::flog.threshold(0)

##### TEST TEAR DOWN #####
futile.logger::flog.threshold(origLogThreshold)
rm(list = ls())
4 changes: 0 additions & 4 deletions r-pkg/tests/testthat/test-parse_date_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ if (!identical(loggerOptions, list())){
}
futile.logger::flog.threshold(0)

context("parse_date_time")


# Correctly adjusts UTC date-times
test_that("parse_date_time should transform the indicated date_cols to POSIXct with timezone UTC if they're given in UTC", {
testDT <- data.table::data.table(
Expand Down Expand Up @@ -176,4 +173,3 @@ test_that("parse_date_time should leave the original DT unchanged", {

##### TEST TEAR DOWN #####
futile.logger::flog.threshold(origLogThreshold)
rm(list = ls())
3 changes: 0 additions & 3 deletions r-pkg/tests/testthat/test-unpack_nested_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ if (!identical(loggerOptions, list())){
}
futile.logger::flog.threshold(0)

context("Elasticsearch result-parsing functions")

#--- unpack_nested_data

# Should work with result of chomp_hits
Expand Down Expand Up @@ -112,4 +110,3 @@ context("Elasticsearch result-parsing functions")

##### TEST TEAR DOWN #####
futile.logger::flog.threshold(origLogThreshold)
rm(list = ls())

0 comments on commit ffa29b0

Please sign in to comment.