Try this:
test_that("connection will work", {
txt <- ""
con <- textConnection("txt", "w",local = TRUE)
writeLines("test data", con)
close(con)
expect_equal(txt, "test data")
})
I got there from my hunch that the fact that test_that
evaluates code within a separate environment was connected to the problem, and then checking the documentation on textConnection
.