-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* migrate tests to testtthat edition 3 * update github actions
- Loading branch information
1 parent
4a7363e
commit a7616d6
Showing
15 changed files
with
627 additions
and
548 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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
library(testthat) | ||
library(wdman) | ||
|
||
# if (identical(tolower(Sys.getenv("NOT_CRAN")), "true")) { | ||
# test_check("wdman") | ||
# } | ||
if (identical(tolower(Sys.getenv("NOT_CRAN")), "true")) { | ||
test_check("wdman") | ||
} | ||
|
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 |
---|---|---|
@@ -1,96 +1,117 @@ | ||
context("chrome") | ||
|
||
normalizePath <- function(...) base::normalizePath(...) | ||
list.files <- function(...) base::list.files(...) | ||
|
||
test_that("canCallChrome", { | ||
with_mock( | ||
`binman::process_yaml` = binman_process_yaml, | ||
`binman::list_versions` = mock_binman_list_versions_chrome, | ||
`binman::app_dir` = mock_binman_app_dir, | ||
local_mocked_bindings( | ||
process_yaml = binman_process_yaml, | ||
list_versions = mock_binman_list_versions_chrome, | ||
app_dir = mock_binman_app_dir, | ||
) | ||
local_mocked_bindings( | ||
normalizePath = mock_base_normalizePath, | ||
list.files = mock_base_list.files, | ||
`subprocess::spawn_process` = mock_subprocess_spawn_process, | ||
`subprocess::process_return_code` = | ||
mock_subprocess_process_return_code, | ||
`subprocess::process_kill` = mock_subprocess_process_kill, | ||
`wdman:::generic_start_log` = mock_generic_start_log, | ||
`wdman:::infun_read` = function(...) { | ||
.package = "base", | ||
) | ||
local_mocked_bindings( | ||
check_bindings = function(...) {}, | ||
.package = "testthat" | ||
) | ||
local_mocked_bindings( | ||
process = mock_processx_process, | ||
.package = "processx" | ||
) | ||
local_mocked_bindings( | ||
generic_start_log = mock_generic_start_log, | ||
infun_read = function(...) { | ||
"infun" | ||
}, | ||
{ | ||
cDrv <- chrome() | ||
retCommand <- chrome(retcommand = TRUE) | ||
expect_identical(cDrv$output(), "infun") | ||
expect_identical(cDrv$error(), "infun") | ||
logOut <- cDrv$log()[["stdout"]] | ||
logErr <- cDrv$log()[["stderr"]] | ||
expect_identical(logOut, "super duper") | ||
expect_identical(logErr, "no error here") | ||
expect_identical(cDrv$stop(), "stopped") | ||
} | ||
) | ||
expect_identical(cDrv$process, "hello") | ||
kill_process = mock_subprocess_process_kill, | ||
) | ||
|
||
cDrv <- chrome() | ||
retCommand <- chrome(retcommand = TRUE) | ||
expect_identical(cDrv$output(), "infun") | ||
expect_identical(cDrv$error(), "infun") | ||
logOut <- cDrv$log()[["stdout"]] | ||
logErr <- cDrv$log()[["stderr"]] | ||
expect_identical(logOut, "super duper") | ||
expect_identical(logErr, "no error here") | ||
expect_identical(cDrv$stop(), "stopped") | ||
expect_identical(cDrv$process$test, "hello") | ||
expect_identical( | ||
retCommand, | ||
"some.path --port=4567 --url-base=wd/hub --verbose" | ||
) | ||
}) | ||
|
||
test_that("chrome_verErrorWorks", { | ||
with_mock( | ||
`binman::list_versions` = mock_binman_list_versions_chrome, | ||
expect_error( | ||
wdman:::chrome_ver("linux64", "noversion"), | ||
"doesnt match versions" | ||
) | ||
local_mocked_bindings( | ||
list_versions = mock_binman_list_versions_chrome, | ||
) | ||
|
||
expect_error( | ||
wdman:::chrome_ver("linux64", "noversion"), | ||
"doesnt match versions" | ||
) | ||
}) | ||
|
||
test_that("pickUpErrorFromReturnCode", { | ||
with_mock( | ||
`binman::process_yaml` = function(...) {}, | ||
`binman::list_versions` = mock_binman_list_versions_chrome, | ||
`binman::app_dir` = mock_binman_app_dir, | ||
local_mocked_bindings( | ||
process_yaml = binman_process_yaml, | ||
list_versions = mock_binman_list_versions_chrome, | ||
app_dir = mock_binman_app_dir, | ||
) | ||
local_mocked_bindings( | ||
normalizePath = mock_base_normalizePath, | ||
list.files = mock_base_list.files, | ||
`subprocess::spawn_process` = mock_subprocess_spawn_process, | ||
`subprocess::process_return_code` = function(...) { | ||
"some error" | ||
}, | ||
`subprocess::process_read` = | ||
mock_subprocess_process_read_selenium, | ||
`wdman:::generic_start_log` = mock_generic_start_log, | ||
{ | ||
expect_error( | ||
chrome(version = "2.24"), | ||
"Chromedriver couldn't be started" | ||
) | ||
} | ||
.package = "base" | ||
) | ||
local_mocked_bindings( | ||
check_bindings = function(...) {}, | ||
.package = "testthat" | ||
) | ||
local_mocked_bindings( | ||
process = mock_processx_process_fail, | ||
.package = "processx" | ||
) | ||
local_mocked_bindings( | ||
generic_start_log = mock_generic_start_log, | ||
) | ||
|
||
expect_error( | ||
chrome(), | ||
"Chromedriver couldn't be started" | ||
) | ||
}) | ||
|
||
test_that("pickUpErrorFromPortInUse", { | ||
with_mock( | ||
`binman::process_yaml` = function(...) {}, | ||
`binman::list_versions` = mock_binman_list_versions_chrome, | ||
`binman::app_dir` = mock_binman_app_dir, | ||
local_mocked_bindings( | ||
process_yaml = binman_process_yaml, | ||
list_versions = mock_binman_list_versions_chrome, | ||
app_dir = mock_binman_app_dir, | ||
) | ||
local_mocked_bindings( | ||
normalizePath = mock_base_normalizePath, | ||
list.files = mock_base_list.files, | ||
`subprocess::spawn_process` = mock_subprocess_spawn_process, | ||
`subprocess::process_return_code` = | ||
mock_subprocess_process_return_code, | ||
`subprocess::process_read` = | ||
mock_subprocess_process_read_selenium, | ||
`subprocess::process_kill` = mock_subprocess_process_kill, | ||
`wdman:::generic_start_log` = function(...) { | ||
.package = "base" | ||
) | ||
local_mocked_bindings( | ||
check_bindings = function(...) {}, | ||
.package = "testthat" | ||
) | ||
local_mocked_bindings( | ||
process = mock_processx_process, | ||
.package = "processx" | ||
) | ||
local_mocked_bindings( | ||
generic_start_log = function(...) { | ||
list(stderr = "Address already in use") | ||
}, | ||
{ | ||
expect_error( | ||
chrome(version = "2.24"), | ||
"Chrome Driver signals port" | ||
) | ||
} | ||
kill_process = mock_subprocess_process_kill | ||
) | ||
|
||
expect_error( | ||
chrome(), | ||
"Chrome Driver signals port" | ||
) | ||
}) |
Oops, something went wrong.