Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAxthelm committed Apr 9, 2024
1 parent e720d60 commit 702a752
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
7 changes: 5 additions & 2 deletions R/get_environment.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
#'
#' @return nested list of file details, length the same as the input vector.
get_manifest_envirionment_info <- function() {
#: Envvars
return(invisible(NULL))
environment_list <- list(
session = get_r_session_info(),
packages = get_package_info()
)
return(environment_list)
}

#' Get session information for manifest
Expand Down
46 changes: 42 additions & 4 deletions tests/testthat/test-get_environment.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ logger::log_appender(logger::appender_stdout)
logger::log_threshold(logger::FATAL)
logger::log_layout(logger::layout_simple)

test_that("get_single_file_metadata processes CSV tables correctly", {
test_that("get_r_session_info returns expected values", {
expect_identical(
get_r_session_info(),
list(
Expand All @@ -27,6 +27,44 @@ test_that("get_single_file_metadata processes CSV tables correctly", {
)
})

testthat::expect_null(
get_manifest_envirionment_info()
)
test_that("get_environment_info returns expected structure", {
suppressWarnings({ # warnings from `load_all` are expected
env_info <- get_manifest_envirionment_info()
})
expect_type(env_info, "list")
expect_named(
object = env_info,
expected = c("session", "packages")
)
expect_named(
object = env_info[["session"]],
expected = c(
"R.version",
"platform",
"running",
"locale",
"tzone",
"libPaths"
)
)
expect_named(
object = env_info[["packages"]],
expected = c(
"base",
"attached",
"loaded"
)
)
expect_named(
object = env_info[["packages"]][["base"]],
expected = utils::sessionInfo()[["basePkgs"]]
)
expect_named(
object = env_info[["packages"]][["attached"]],
expected = names(utils::sessionInfo()[["otherPkgs"]])
)
expect_named(
object = env_info[["packages"]][["loaded"]],
expected = names(utils::sessionInfo()[["loadedOnly"]])
)
})

0 comments on commit 702a752

Please sign in to comment.