File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -680,7 +680,7 @@ querychat_app <- function(
680680 cleanup <-
681681 is.data.frame(data_source ) &&
682682 ! in_shiny_session() &&
683- interactive ()
683+ is_interactive ()
684684 }
685685
686686 qc <- QueryChat $ new(
Original file line number Diff line number Diff line change @@ -306,3 +306,39 @@ describe("normalize_data_source()", {
306306 })
307307 })
308308})
309+
310+ test_that(" querychat_app() only cleans up data frame sources on exit" , {
311+ local_mocked_r6_class(
312+ QueryChat ,
313+ public = list (
314+ initialize = function (... , cleanup ) {
315+ # have to use an option because the code is evaluated in a far-away env
316+ options(.test_cleanup = cleanup )
317+ },
318+ app = function (... ) {}
319+ )
320+ )
321+ withr :: local_options(rlang_interactive = TRUE )
322+
323+ withr :: with_options(list (.test_cleanup = NULL ), {
324+ test_df <- new_test_df()
325+ querychat_app(test_df )
326+ cleanup_result <- getOption(" .test_cleanup" )
327+ expect_true(cleanup_result )
328+ })
329+
330+ withr :: with_options(list (.test_cleanup = NULL ), {
331+ test_ds <- local_data_frame_source(new_test_df())
332+ querychat_app(test_ds )
333+ cleanup_result <- getOption(" .test_cleanup" )
334+ expect_false(cleanup_result )
335+ })
336+
337+ withr :: with_options(list (.test_cleanup = NULL ), {
338+ con <- local_sqlite_connection(new_test_df())
339+ test_ds <- DBISource $ new(con $ conn , " test_table" )
340+ querychat_app(test_ds )
341+ cleanup_result <- getOption(" .test_cleanup" )
342+ expect_false(cleanup_result )
343+ })
344+ })
You can’t perform that action at this time.
0 commit comments