Skip to content

Instantly share code, notes, and snippets.

@alandipert
Created April 28, 2020 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alandipert/c1f3a56d99bf8a9186178b5ad271c7dd to your computer and use it in GitHub Desktop.
Save alandipert/c1f3a56d99bf8a9186178b5ad271c7dd to your computer and use it in GitHub Desktop.
library(promises)
library(future)
library(shiny)
library(testthat)
plan(multiprocess)
adderModule <- function(id, sleepFor, n) {
moduleServer(id, function(input, output, session) {
output$sum <- renderText({
future({ Sys.sleep(sleepFor); n }) %...>%
{ . + input$n } %...>%
as.character()
})
})
}
testServer(adderModule, {
session$setInputs(n = 10)
timing <- system.time({
expect_equal(output$sum, "20")
})
expect_gt(timing[[3]], 4)
}, sleepFor = 5, n = 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment