Skip to content

Commit

Permalink
refactor gecko test
Browse files Browse the repository at this point in the history
  • Loading branch information
johndharrison committed Dec 8, 2016
1 parent f6f6d2b commit b02e257
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
9 changes: 9 additions & 0 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mock_binman_list_versions_chrome <- function(...){
win32 = c("2.23", "2.24", "2.25")
)
}

mock_binman_list_versions_phantomjs <- function(...){
list(
linux32 = c("1.9.7", "1.9.8", "2.1.1"),
Expand All @@ -15,6 +16,14 @@ mock_binman_list_versions_phantomjs <- function(...){
windows = c("1.9.8", "2.0.0", "2.1.1")
)
}

mock_binman_list_versions_gecko <- function(...){
list(
linux64 = c("v0.10.0", "v0.11.0", "v0.11.1"),
macos = c("v0.10.0", "v0.11.0", "v0.11.1"),
win64 = c("v0.10.0", "v0.11.0", "v0.11.1")
)
}
mock_base_normalizePath <- function(path, winslash, mustWork){
path
}
Expand Down
29 changes: 7 additions & 22 deletions tests/testthat/test-gecko.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,13 @@ context("gecko")
test_that("canCallChromeGecko", {
with_mock(
`binman::process_yaml` = function(...){},
`binman::list_versions` = function(...){
list(
linux64 = c("v0.10.0", "v0.11.0", "v0.11.1"),
macos = c("v0.10.0", "v0.11.0", "v0.11.1"),
win64 = c("v0.10.0", "v0.11.0", "v0.11.1")
)
},
`binman::app_dir` = function(...){
"some.dir"
},
`base::normalizePath` = function(path, winslash, mustWork){
path
},
`base::list.files` = function(...){
"some.path"
},
`subprocess::spawn_process` = function(...){
"hello"
},
`subprocess::process_return_code` = function(...){
NA
},
`binman::list_versions` = mock_binman_list_versions_gecko,
`binman::app_dir` = mock_binman_app_dir,
`base::normalizePath` = mock_base_normalizePath,
`base::list.files` = mock_base_list.files,
`subprocess::spawn_process` = mock_subprocess_spawn_process,
`subprocess::process_return_code` =
mock_subprocess_process_return_code,
gDrv <- gecko()
)
expect_identical(gDrv$process, "hello")
Expand Down

0 comments on commit b02e257

Please sign in to comment.