tests/testthat/test-parallel.R

test_that("parallel", {

  do <- async(function() {
    dx1 <- http_get(http$url("/get", query = list(q = "foo")))$
      then( function(.) rawToChar(.$content))
    dx2 <- http_get(http$url("/get", query = list(q = "bar")))$
      then( function(.) rawToChar(.$content))

    when_all(
      dx1$then(function(.) expect_match(., "\"q\":[ ]*\"foo\"")),
      dx2$then(function(.) expect_match(., "\"q\":[ ]*\"bar\""))
    )
  })
  synchronise(do())
})
gaborcsardi/async documentation built on Nov. 20, 2024, 4:51 p.m.