tests/testthat/test-app-loading.R

# test_that("app ui", {
#   ui <- app_ui()
#   golem::expect_shinytaglist(ui)
#   # Check that formals have not been removed
#   fmls <- formals(app_ui)
#   for (i in c("request")) {
#     expect_true(i %in% names(fmls))
#   }
# })
#
# test_that("app server", {
#   server <- app_server
#   expect_type(server, "closure")
#   # Check that formals have not been removed
#   fmls <- formals(app_server)
#   for (i in c("input", "output", "session")) {
#     expect_true(i %in% names(fmls))
#   }
# })
#
# test_that(
#   "app_sys works",
#   {
#     expect_true(
#       app_sys("golem-config.yml") != ""
#     )
#   }
# )
#
# test_that(
#   "golem-config works",
#   {
#     config_file <- app_sys("golem-config.yml")
#     skip_if(config_file == "")
#
#     expect_true(
#       get_golem_config(
#         "app_prod",
#         config = "production",
#         file = config_file
#       )
#     )
#     expect_false(
#       get_golem_config(
#         "app_prod",
#         config = "dev",
#         file = config_file
#       )
#     )
#   }
# )



test_that(
  "DHS survey metadata successfully loaded",
  {
    expect_true(
      !is.null(DHS.country.meta)
    )
    expect_true(
      !is.null(DHS.survey.meta)
    )
    expect_true(
      !is.null(DHS.dataset.meta)
    )
  }
)



# Configure this test to fit your need.
# testServer() function makes it possible to test code in server functions and modules, without needing to run the full Shiny application
# testServer(app_server, {
#
#   # Set and test an input
#   session$setInputs(x = 2)
#   expect_equal(input$x, 2)
#
#   # Example of tests you can do on the server:
#   # - Checking reactiveValues
#   # expect_equal(r$lg, 'EN')
#   # - Checking output
#   # expect_equal(output$txt, "Text")
# })

Try the sae4health package in your browser

Any scripts or data that you put into this service are public.

sae4health documentation built on June 8, 2025, 10:43 a.m.