diff --git a/drivers/windows/tests/testthat/test-batch.R b/drivers/windows/tests/testthat/test-batch.R index d90d1952..2df589be 100644 --- a/drivers/windows/tests/testthat/test-batch.R +++ b/drivers/windows/tests/testthat/test-batch.R @@ -24,9 +24,8 @@ test_that("batch data creates entries for share drives", { expect_equal(dat$hermod_root_drive, "X:") expect_equal(dat$hermod_root_path, "\\b\\c") - expected <- sprintf( - "hermod/lib/windows/%s;//fi--didef3.dide.ic.ac.uk/tmp/hermod-testing", - version_string(config$r_version, ".")) + v <- version_string(config$r_version, ".") + expected <- sprintf("hermod/lib/windows/%s;I:/bootstrap/%s", v, v) expect_equal(dat$hermod_library, expected) }) diff --git a/drivers/windows/tests/testthat/test-bootstrap.R b/drivers/windows/tests/testthat/test-bootstrap.R new file mode 100644 index 00000000..8587a596 --- /dev/null +++ b/drivers/windows/tests/testthat/test-bootstrap.R @@ -0,0 +1,15 @@ +test_that("can run bootstrap", { + mount <- withr::local_tempfile() + root <- example_root(mount, "b/c") + mock_hermod_provision <- mockery::mock() + mockery::stub(bootstrap_update, "hermod::hermod_provision", + mock_hermod_provision) + + bootstrap_update(root) + mockery::expect_called(mock_hermod_provision, 1) + expect_true(file.exists( + file.path(root$path$root, "hermod", "bootstrap-windows.R"))) + expect_equal( + mockery::mock_args(mock_hermod_provision)[[1]], + list("script", script = "hermod/bootstrap-windows.R", root = root)) +}) diff --git a/drivers/windows/tests/testthat/test-config.R b/drivers/windows/tests/testthat/test-config.R index 8b1b1e99..c629b4b1 100644 --- a/drivers/windows/tests/testthat/test-config.R +++ b/drivers/windows/tests/testthat/test-config.R @@ -13,8 +13,7 @@ test_that("Can create configuration", { expect_equal(config$shares, list(shares)) expect_equal(config$r_version, numeric_version("4.3.0")) expect_equal(config$path_lib, "hermod/lib/windows/4.3.0") - expect_equal(config$path_bootstrap, - "//fi--didef3.dide.ic.ac.uk/tmp/hermod-testing") + expect_equal(config$path_bootstrap, "I:/bootstrap/4.3.0") }) diff --git a/drivers/windows/tests/testthat/test-provision.R b/drivers/windows/tests/testthat/test-provision.R index 234509a9..525485e2 100644 --- a/drivers/windows/tests/testthat/test-provision.R +++ b/drivers/windows/tests/testthat/test-provision.R @@ -13,18 +13,18 @@ test_that("can run provision script", { config <- root$config$windows msg <- capture_messages( - windows_provision("script", config, path_root, poll = 0)) + windows_provision("script", config, path_root, NULL, poll = 0)) mockery::expect_called(mock_get_client, 1) expect_equal(mockery::mock_args(mock_get_client)[[1]], list()) mockery::expect_called(mock_client$submit, 1) args <- mockery::mock_args(mock_client$submit)[[1]] - expect_match(args[[2]], "^[[:xdigit:]]{32}$") + expect_match(args[[2]], "^conan:[[:xdigit:]]{32}$") id <- args[[2]] batch_path <- windows_path(file.path( "//host.dide.ic.ac.uk/share/path/b/c/hermod/provision", - id, + sub("^conan:", "", id), "provision.bat")) expect_equal(args, list(batch_path, id, "BuildQueue")) @@ -46,6 +46,7 @@ test_that("error on provision script failure", { path_root <- root$path$root config <- root$config$windows expect_error( - suppressMessages(windows_provision("script", config, path_root, poll = 0)), + suppressMessages( + windows_provision("script", config, path_root, NULL, poll = 0)), "Installation failed") }) diff --git a/drivers/windows/tests/testthat/test-util.R b/drivers/windows/tests/testthat/test-util.R index 5344e9ca..e61b4a36 100644 --- a/drivers/windows/tests/testthat/test-util.R +++ b/drivers/windows/tests/testthat/test-util.R @@ -115,3 +115,23 @@ test_that("readlines from file if exists returns null if file missing", { writeLines(c("a", "b"), path) expect_equal(readlines_if_exists(path), c("a", "b")) }) + + +test_that("writelines_if_not_exists updates files when different", { + path <- withr::local_tempfile() + writelines_if_different(c("a", "b"), path) + expect_equal(readLines(path), c("a", "b")) + + writelines_if_different(c("a", "b", "c"), path) + expect_equal(readLines(path), c("a", "b", "c")) +}) + + +test_that("writelines_if_not_exists does not update file when not different", { + path <- withr::local_tempfile() + writeLines(c("a", "b"), path) + mock_writelines <- mockery::mock() + mockery::stub(writelines_if_different, "writeLines", mock_writelines) + writelines_if_different(c("a", "b"), path) + mockery::expect_called(mock_writelines, 0) +})