-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4734dc8
commit f3455dd
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# errors informatively on .pal_app error | ||
|
||
Code | ||
.init_addin() | ||
Condition | ||
Error: | ||
! some error | ||
|
||
# errors informatively with missing binding | ||
|
||
Code | ||
.init_addin() | ||
Condition | ||
Error: | ||
! Unable to locate the requested pal. | ||
|
||
# .init_addin executes found binding | ||
|
||
Code | ||
res <- .init_addin() | ||
Message | ||
howdy! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
test_that(".init_addin exits early with missing selection", { | ||
testthat::local_mocked_bindings(.pal_app = function() NULL) | ||
expect_null(.init_addin()) | ||
}) | ||
|
||
test_that(".init_addin exits early with empty selection", { | ||
testthat::local_mocked_bindings(.pal_app = function() ".pal_rs_") | ||
expect_null(.init_addin()) | ||
}) | ||
|
||
test_that("errors informatively on .pal_app error", { | ||
testthat::local_mocked_bindings( | ||
.pal_app = function() cli::cli_abort("some error") | ||
) | ||
expect_snapshot(.init_addin(), error = TRUE) | ||
}) | ||
|
||
test_that("errors informatively with missing binding", { | ||
testthat::local_mocked_bindings( | ||
.pal_app = function() ".pal_rs_some_fn", | ||
env_get = function(...) cli::cli_abort("nope.") | ||
) | ||
expect_snapshot(.init_addin(), error = TRUE) | ||
}) | ||
|
||
test_that(".init_addin executes found binding", { | ||
mock_fn <- function() cli::cli_inform("howdy!") | ||
testthat::local_mocked_bindings( | ||
.pal_app = function() ".pal_rs_mock", | ||
env_get = function(...) mock_fn | ||
) | ||
expect_snapshot(res <- .init_addin()) | ||
expect_null(res) | ||
}) |