Skip to content

Commit

Permalink
Add version to returned bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
stefpiatek committed Aug 29, 2024
1 parent 96da9f1 commit 02e3994
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions R/bundles.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @description If a bundle has multiple names, then the id will be duplicated across rows
#'
#' @param version Requested version, if not defined, the latest will be used
#' @return dataframe that contains a concept_name and a domain column for each available concept
#' @return dataframe that contains a "concept_name", "version" and a "domain" column for each available concept
#' @export
#' @examples
#' available_bundles()
Expand All @@ -17,7 +17,8 @@ available_bundles <- function(version = "latest") {
directories <- list.dirs(raw_dir, full.names = TRUE)
domain_directories <- directories[directories != raw_dir]

purrr::map_dfr(domain_directories, .build_concepts_from_directory)
purrr::map_dfr(domain_directories, .build_concepts_from_directory) |>
mutate(version = version)
}

.get_raw_dir <- function(...) {
Expand Down
9 changes: 7 additions & 2 deletions tests/testthat/test-bundles.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ library(omopbundles)
library(testthat)


test_that("available_bundles is not empty", {
result <- available_bundles()
test_that("available_bundles isn't empty and have correct columns", {
result <- omopbundles::available_bundles()
expect_true(nrow(result) > 0, info = "The dataframe should not be empty")
hiv_ab <- filter(result, concept_name == "antibodies to hiv")
expect_equal(hiv_ab$version, "latest")
expect_equal(hiv_ab$id, "antibodies_to_hiv.csv")
expect_equal(hiv_ab$domain, "measurement")

})

test_that("Smoking exists as an observation", {
Expand Down

0 comments on commit 02e3994

Please sign in to comment.