Skip to contents

Loads specified preload lists to verify execution, saves the state to the specified zip file and attempts to load the saved state if test_save_state is TRUE. To test a workflow you can use sources to specify the loading of data and then workflow to specify the yaml workflow.

Usage

ASM_test_preload(
  sources = NULL,
  preload_files = NULL,
  preload_dir = tempfile(pattern = "preload_"),
  save_state_file = tempfile(fileext = ".zip"),
  test_save_state = TRUE,
  workflow = NULL
)

Arguments

sources

Vector of at corresponds with the ID used to call the modules UI elements

preload_files

Dataframe of files needed to run the workflow with a column called src for the local source of the file and dest for the destination. Not strictly required but almost always needed.

preload_dir

Directory to run out of (tempdir())

save_state_file

When testing `ASM_save_state()` this is the file name where the stat will be written (tempfile(fileext=".zip"))

test_save_state

Logical when set to TRUE (default) it will test the zip file (save_state_file) to make sure it can be loaded.

workflow

Yaml preload file to run a workflow (optional, NULL default).

Value

list with the following elements

  • isgood: Boolean indicating the exit status of the function.

  • msgs: Messages to be passed back to the user.

  • apl_res: Results from FM_app_preload() if run, list(isgood=FALSE, msgs="not run") otherwise.

  • ss_res: Results from ASM_save_state() if run, list(isgood=FALSE, msgs="not run") otherwise.

  • ls_res: Results from ASM_load_state() if run, list(isgood=FALSE, msgs="not run") otherwise.

  • rwf_res: Results from ASM_run_workflow() if run, list(isgood=FALSE, msgs="not run") otherwise.

  • save_state_file: If ss_res$isgood is TRUE this is the path to the zip file generated when saving the app state after loading.

Examples


sources = c(
 system.file(package="formods", "preload", "UD_preload.yaml"),
 system.file(package="formods", "preload", "ASM_preload.yaml"))

res = ASM_test_preload(sources=sources, test_save_state = FALSE)
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → ASM:   dest:   file.path("config","report.docx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → ASM:   dest:   file.path("config","report.pptx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → ASM:   dest:   file.path("config","report.yaml")
#> → ASM: State initialized
#> → ASM: setting word placeholders: 
#> → ASM:   -> setting docx ph: HEADERLEFT = left header
#> → ASM:   -> setting docx ph: HEADERRIGHT = right header
#> → ASM:   -> setting docx ph: FOOTERLEFT = left footer
#> → ASM: module isgood: TRUE
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → UD:   dest:   file.path("config","report.docx")
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → UD:   dest:   file.path("config","report.pptx")
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → UD:   dest:   file.path("config","report.yaml")
#> → UD: State initialized
#> → UD: module checksum updated:897d952fecbc804999396a96f9df4b20
#> → UD: module isgood: TRUE
#> → # preload_complete is good: TRUE ------------------------------------------
#> → Saving module: ASM
#> → ASM: mk_preload isgood: TRUE
#> → Saving module: UD
#> → UD: mk_preload isgood: TRUE
#> → ASM: writing app state to file on server: 
#> → ASM:   /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//Rtmpt88VfY/file5d8636484e56.zip
#> → ASM: Generating reports (code only)
#> → ASM: done writing app state

res$isgood
#> [1] TRUE