context("batching while caching")
db_test_that("it does not call batchman::batch when uncached keys do not exceed batch size", {
env <- list2env(list(called = FALSE))
package_stub("batchman", "batch", function(fn, ...) { env$called <- TRUE; fn }, {
expect_cached({
df_ref <- batch_data(1:100)
df_cached <- cached_fcn(key = 1:100, model_version, type)
})
expect_false(env$called)
})
})
db_test_that("it calls batchman::batch when uncached keys exceed batch size", {
env <- list2env(list(called = FALSE))
package_stub("batchman", "batch", function(fn, ...) { env$called <- TRUE; fn }, {
expect_cached({
df_ref <- batch_data(1:101)
df_cached <- cached_fcn(key = 1:101, model_version, type)
})
expect_true(env$called)
})
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.