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

[R-package] switch to SummaryReporter, remove context(), other testthat changes #232

Merged
merged 1 commit into from
Jan 28, 2025
Merged
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
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())
Loading