Skip to content

Commit

Permalink
Add windows username into reported configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Jan 3, 2024
1 parent 2960cd8 commit ce6b6e5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
11 changes: 10 additions & 1 deletion R/configuration.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@ configuration_paths <- function(root) {


configuration_drivers <- function(root) {
root$config
ret <- root$config
if (!is.null(ret$windows)) {
## This is not really part of the configuration (because windows
## username/password are saved globally), but we will add it here
## because it's useful to report, and this is where we'd want it
## reported. We could add this into the configuration itself, but
## that causes some pain for the testing there.
ret$windows$username <- windows_username()
}
ret
}


Expand Down
25 changes: 25 additions & 0 deletions tests/testthat/test-configuration.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,28 @@ test_that("can report about everything being missing", {
c("x" = "hipercow.windows is not installed",
"x" = "conan2 is not installed"))
})


test_that("can add windows username to configuration", {
elsewhere_register()
path_here <- withr::local_tempdir()
path_there <- withr::local_tempdir()
init_quietly(path_here)
init_quietly(path_there)
root <- hipercow_root(path_here)
suppressMessages(
hipercow_configure("elsewhere", path = path_there, root = path_here))

mock_username <- mockery::mock("alice")
mockery::stub(configuration_drivers, "windows_username", mock_username)
res <- configuration_drivers(root)
mockery::expect_called(mock_username, 0)
expect_equal(res, root$config)

root$config <- c(root$config, list(windows = list(a = 1, b = 2)))
res <- configuration_drivers(root)
mockery::expect_called(mock_username, 1)
cmp <- root$config
cmp$windows$username <- "alice"
expect_equal(res, cmp)
})

0 comments on commit ce6b6e5

Please sign in to comment.