Skip to content

Commit

Permalink
Use duckdb in unit tests
Browse files Browse the repository at this point in the history
Sqlite doesn't support `lubridate::quarter()` and we're only using
duckdb or Postgres in our applications anyway.
  • Loading branch information
milanmlft committed Nov 20, 2024
1 parent eebdf48 commit f158e9d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions preprocessing/tests/testthat/test-monthly_counts.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit f158e9d

Please sign in to comment.