From 74a69a3a1fd66e930802ce6e461538c9e15f7c86 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Tue, 27 Jun 2023 08:59:01 -0700 Subject: [PATCH] Use expect_no_error over custom helper (#435) --- DESCRIPTION | 2 +- tests/testthat/helper.R | 4 ---- tests/testthat/test-drive_auth.R | 4 ++-- tests/testthat/test-drive_id-class.R | 8 ++++---- tests/testthat/test-utils-paths.R | 4 ++-- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0f63a5300..7fa9d8f1a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,7 +37,7 @@ Suggests: mockr, rmarkdown, spelling, - testthat (>= 3.1.3) + testthat (>= 3.1.5) VignetteBuilder: knitr Config/Needs/website: diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index a6870da00..329d49a3d 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -17,10 +17,6 @@ with_mock <- function(..., .parent = parent.frame()) { mockr::with_mock(..., .parent = .parent, .env = "googledrive") } -expect_error_free <- function(...) { - expect_error(..., regexp = NA) -} - # usage: # test_fixture("something.rds") test_fixture <- function(name) testthat::test_path("test-fixtures", name) diff --git a/tests/testthat/test-drive_auth.R b/tests/testthat/test-drive_auth.R index 7af5b1e7b..6a86f4a12 100644 --- a/tests/testthat/test-drive_auth.R +++ b/tests/testthat/test-drive_auth.R @@ -5,8 +5,8 @@ test_that("drive_auth_configure works", { drive_auth_configure(client = old_client, api_key = old_api_key) ) - expect_error_free(drive_oauth_client()) - expect_error_free(drive_api_key()) + expect_no_error(drive_oauth_client()) + expect_no_error(drive_api_key()) expect_snapshot( drive_auth_configure(client = gargle::gargle_client(), path = "PATH"), diff --git a/tests/testthat/test-drive_id-class.R b/tests/testthat/test-drive_id-class.R index 3c93ccf27..22259484f 100644 --- a/tests/testthat/test-drive_id-class.R +++ b/tests/testthat/test-drive_id-class.R @@ -72,7 +72,7 @@ test_that("presence of drive_id column doesn't prevent row binding of dribbles", alfa <- x[1:2, ] bravo <- x[3:4, ] - expect_error_free( + expect_no_error( out <- vec_rbind(alfa, bravo) ) expect_equal(out[c("name", "id")], x[1:4, c("name", "id")]) @@ -102,19 +102,19 @@ test_that("gargle_map_cli() is implemented for drive_id", { ## low-level helpers test_that("new_drive_id() handles 0-length input and NA", { - expect_error_free( + expect_no_error( out <- new_drive_id(character()) ) expect_length(out, 0) expect_true(is_drive_id(out)) - expect_error_free( + expect_no_error( out <- new_drive_id(NA_character_) ) expect_true(is.na(out)) expect_true(is_drive_id(out)) - expect_error_free( + expect_no_error( out <- new_drive_id(c(NA_character_, "abc")) ) expect_true(is.na(out[1])) diff --git a/tests/testthat/test-utils-paths.R b/tests/testthat/test-utils-paths.R index 3b528b671..61b479654 100644 --- a/tests/testthat/test-utils-paths.R +++ b/tests/testthat/test-utils-paths.R @@ -171,7 +171,7 @@ test_that("check_for_overwrite() does its job", { "already exist" ) - expect_error_free( + expect_no_error( second <- drive_create( me_("name-collision"), path = PARENT_ID, @@ -185,7 +185,7 @@ test_that("check_for_overwrite() does its job", { ) expect_false(first$id == second$id) - expect_error_free( + expect_no_error( drive_create( me_("name-collision"), path = PARENT_ID,