Skip to content

Commit

Permalink
Properly mock base::Sys.info().
Browse files Browse the repository at this point in the history
  • Loading branch information
jonthegeek committed Aug 15, 2024
1 parent 6b412ed commit 7b83144
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 2 additions & 0 deletions R/mocks.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Define these objects so they can be mocked in tests.
Sys.info <- NULL
15 changes: 3 additions & 12 deletions tests/testthat/test-default-backend.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,12 @@ test_that("mixing options and env vars", {
})

test_that("auto windows", {
local_mocked_bindings(
Sys.info = function() c(sysname = "Windows"),
.package = "base"
)
local_mocked_bindings(Sys.info = function() c(sysname = "Windows"))
expect_equal(default_backend_auto(), backend_wincred)
})

test_that("auto macos", {
local_mocked_bindings(
Sys.info = function() c(sysname = "Darwin"),
.package = "base"
)
local_mocked_bindings(Sys.info = function() c(sysname = "Darwin"))
expect_equal(default_backend_auto(), backend_macos)
})

Expand All @@ -72,9 +66,6 @@ test_that("auto linux", {
})

test_that("auto other", {
local_mocked_bindings(
Sys.info = function() c(sysname = "Solaris"),
.package = "base"
)
local_mocked_bindings(Sys.info = function() c(sysname = "Solaris"))
expect_equal(suppressWarnings(default_backend_auto()), backend_file)
})

0 comments on commit 7b83144

Please sign in to comment.