Skip to content

Commit 527508e

Browse files
committed
Mock cloud launcher tests
1 parent fc393f6 commit 527508e

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

0 commit comments

Comments
 (0)