From f158e9d7205f050106c72449bbe4c8d5729b4c62 Mon Sep 17 00:00:00 2001 From: Milan Malfait <38256462+milanmlft@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:15:19 +0100 Subject: [PATCH] Use `duckdb` in unit tests Sqlite doesn't support `lubridate::quarter()` and we're only using duckdb or Postgres in our applications anyway. --- preprocessing/tests/testthat/test-monthly_counts.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/preprocessing/tests/testthat/test-monthly_counts.R b/preprocessing/tests/testthat/test-monthly_counts.R index dbe0435..f7a8d97 100644 --- a/preprocessing/tests/testthat/test-monthly_counts.R +++ b/preprocessing/tests/testthat/test-monthly_counts.R @@ -39,8 +39,9 @@ test_that("summarise_counts produces the expected results at monthly level", { expect_equal(res$records_per_person, 4 / 3) }) -db <- dbplyr::src_memdb() -db_measurement <- dplyr::copy_to(db, mock_measurement, name = "measurement", overwrite = TRUE) +con <- duckdb::dbConnect(duckdb::duckdb()) +duckdb::duckdb_register(con, "measurement", mock_measurement) +db_measurement <- dplyr::tbl(con, "measurement") test_that("summarise_counts works on Database-stored tables at monthly level", { ref <- summarise_counts(mock_measurement, "measurement_concept_id", "measurement_date", level = "monthly") db_res <- summarise_counts(db_measurement, "measurement_concept_id", "measurement_date", level = "monthly")