Skip to content

Commit

Permalink
test for global_calling_handler
Browse files Browse the repository at this point in the history
  • Loading branch information
lwalejko committed Feb 13, 2024
1 parent 0517753 commit a11588c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/testthat/test-run-api.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,20 @@ testthat::test_that("skips sentry setup if SENTRY_DSN is not set", {
testthat::expect_message(unbiased:::setup_sentry(), "SENTRY_DSN not set, skipping Sentry setup")
testthat::expect_false(was_called)
})

testthat::test_that("global_calling_handler captures exception and signals condition", {
error <- simpleError("test error")

capture_exception_called <- FALSE

testthat::local_mocked_bindings(
capture_exception = function(error) {
capture_exception_called <<- TRUE
testthat::expect_equal(error, error)
},
.package = "sentryR",
)

testthat::expect_error(unbiased:::global_calling_handler(error))
testthat::expect_true(capture_exception_called)
})

0 comments on commit a11588c

Please sign in to comment.