-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from Appsilon/edu.unit-tests
#125 Write unit tests for shiny.i18n package
- Loading branch information
Showing
8 changed files
with
170 additions
and
23 deletions.
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
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
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,32 @@ | ||
context("automatic") | ||
|
||
test_that("translate_with_google_cloud Should error if API is not set", { | ||
|
||
with_mock( | ||
`googleLanguageR::gl_translate` = function(txt_to_translate, target) { | ||
message("Mock: gl_translate called") | ||
stop("forced error") | ||
}, { | ||
# Arrange | ||
txt <- "Hello, how are you?" | ||
target_lang <- "fr" | ||
|
||
# Act | ||
result <- evaluate_promise( | ||
translate_with_google_cloud(txt, target_lang) | ||
) | ||
|
||
} | ||
) | ||
|
||
# Assert | ||
expected_error_messages <- c( | ||
"Mock: gl_translate called\n", | ||
"!!!\n", | ||
"forced error\n", | ||
"Did you set you google cloud API credentials correctly?\n", | ||
"Check how here: https://github.com/ropensci/googleLanguageR/\n" | ||
) | ||
expect_equal(result$message, expected_error_messages) | ||
|
||
}) |
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
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