Skip to content

Commit

Permalink
Use expect_no_error over custom helper (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Jun 27, 2023
1 parent b87d89e commit 74a69a3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Suggests:
mockr,
rmarkdown,
spelling,
testthat (>= 3.1.3)
testthat (>= 3.1.5)
VignetteBuilder:
knitr
Config/Needs/website:
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-drive_auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-drive_id-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")])
Expand Down Expand Up @@ -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]))
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-utils-paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 74a69a3

Please sign in to comment.