tests/testthat/test-sys.R

context('Testing \'sys\'')
if(!requireNamespace("ssh", quietly = TRUE)) {
  skip("ssh package not available.")
}
test_that('exec_wait() works', {
  with_mock(
    `outsider.base:::is_server_connected` = function() FALSE,
    `sys::exec_wait` = function(...) TRUE,
    expect_true(outsider.base:::exec_wait(cmd = 'test'))
  )
  with_mock(
    `outsider.base:::is_server_connected` = function() TRUE,
    `outsider.base:::server_fetch` = function(verbose) 'session_obj',
    `ssh::ssh_exec_wait` = function(...) TRUE,
    expect_true(outsider.base:::exec_wait(cmd = 'test'))
  )
})
test_that('exec_internal() works', {
  with_mock(
    `outsider.base:::is_server_connected` = function() FALSE,
    `sys::exec_internal` = function(...) TRUE,
    expect_true(outsider.base:::exec_internal(cmd = 'test'))
  )
  with_mock(
    `outsider.base:::is_server_connected` = function() TRUE,
    `outsider.base:::server_fetch` = function(verbose) 'session_obj',
    `ssh::ssh_exec_internal` = function(...) TRUE,
    expect_true(outsider.base:::exec_internal(cmd = 'test'))
  )
})

Try the outsider.base package in your browser

Any scripts or data that you put into this service are public.

outsider.base documentation built on April 19, 2021, 1:06 a.m.