-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest-internal_utilities_extra.R
More file actions
38 lines (33 loc) · 1.31 KB
/
Copy pathtest-internal_utilities_extra.R
File metadata and controls
38 lines (33 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
test_that("java_urls_load loads JSON correctly", {
# Real test of the JSON file included in the package
urls <- rJavaEnv:::java_urls_load()
expect_type(urls, "list")
expect_true("Corretto" %in% names(urls))
})
test_that("urls_test_all checks URLs without network", {
# Mock internal loader to return small subset
local_mocked_bindings(
java_urls_load = function() list(
TestDist = list(
linux = list(x64 = "http://example.com/jdk-{version}.tar.gz")
)
),
.package = "rJavaEnv"
)
# Mock curl to avoid network
local_mocked_bindings(
curl_fetch_memory = function(...) list(status_code = 200),
.package = "curl"
)
res <- rJavaEnv:::urls_test_all()
expect_type(res, "list")
expect_equal(res[["TestDist-linux-x64"]]$status, 200)
})
test_that("java_version_check_rscript function exists", {
# We cannot safely test this function without loading rJava, which crashes when
# Java is not configured. Testing the error path is also unsafe because mocking
# base functions like Sys.setenv or list.files interferes with testthat's own operations.
# Instead, we just verify the function exists and has correct structure.
expect_true(exists("java_version_check_rscript", where = asNamespace("rJavaEnv")))
expect_type(rJavaEnv:::java_version_check_rscript, "closure")
})