Skip to content

Commit 2257535

Browse files
committed
Mock cloud launcher tests
1 parent 2a4b0b3 commit 2257535

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

tests/tests.R

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,6 @@ test_true(grepl("5555", local_url(tcp = TRUE, port = 5555), fixed = TRUE))
4242
test_type("list", ssh_config("ssh://remotehost"))
4343
test_type("list", ssh_config("ssh://remotehost", tunnel = TRUE))
4444
test_type("list", cluster_config())
45-
test_error(cloud_config(platform = ""), "not supported")
46-
if (is.null(mirai:::posit_tools())) {
47-
test_error(cloud_config(platform = "posit"), "can only be used from Posit Workbench")
48-
ns <- new.env(parent = emptyenv())
49-
`[[<-`(ns, ".rs.api.launcher.jobsFeatureAvailable", function() TRUE)
50-
`[[<-`(ns, ".rs.api.launcher.getInfo", function() list(clusters = list(list(name = "Kubernetes", defaultImage = "1.a.b.reg.prov.com/int-r-sess:ubuntu2204-20250609"))))
51-
attach(ns, name = "tools:rstudio")
52-
}
53-
test_type("list", cloud_config(platform = "posit"))
5445
test_true(is_mirai_interrupt(r <- mirai:::mk_interrupt_error()))
5546
test_print(r)
5647
test_true(is_mirai_error(r <- `class<-`("Error in: testing\n", c("miraiError", "errorValue", "try-error"))))
@@ -68,6 +59,23 @@ for (i in 0:4)
6859
test_null(register_serial("test_klass1", serialize, unserialize))
6960
test_null(register_serial(c("test_klass2", "test_klass3"), list(serialize, serialize), list(unserialize, unserialize)))
7061
test_equal(length(mirai:::.[["serial"]][[3L]]), 3L)
62+
# cloud launcher tests
63+
test_error(cloud_config(platform = ""), "not supported")
64+
is.null(mirai:::posit_tools()) && {
65+
ns <- new.env(parent = emptyenv())
66+
`[[<-`(ns, ".rs.api.launcher.jobsFeatureAvailable", function() TRUE)
67+
`[[<-`(ns, ".rs.api.launcher.getInfo", function() list(clusters = list(list(name = "Kubernetes", defaultImage = "1.a.b.reg.prov.com/int-r-sess:ubuntu2204-20250609"))))
68+
`[[<-`(ns, ".rs.api.launcher.newContainer", function(image) image)
69+
`[[<-`(ns, ".rs.api.launcher.submitJob", function(...) NULL)
70+
attach(ns, name = "tools:rstudio")
71+
cfg <- cloud_config(platform = "posit")
72+
test_type("list", cfg)
73+
test_zero(daemons(url = local_url(), dispatcher = FALSE))
74+
test_class("miraiLaunchCmd", launch_remote(n = 2L, remote = cfg))
75+
test_zero(daemons(0))
76+
detach()
77+
test_error(cloud_config(platform = "posit"), "can only be used from Posit Workbench")
78+
}
7179
# mirai and daemons tests
7280
connection && {
7381
Sys.sleep(1L)

0 commit comments

Comments
 (0)