Skip to content

Commit

Permalink
Merge pull request #119 from hubverse-org/ak/bug-col-class/118
Browse files Browse the repository at this point in the history
  • Loading branch information
annakrystalli authored Sep 11, 2024
2 parents 7411a71 + 03bffa4 commit 640f680
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: hubValidations
Title: Testing framework for hubverse hub validations
Version: 0.6.1
Version: 0.6.2
Authors@R: c(
person(
given = "Anna",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# hubValidations 0.6.2

* Fixed bug in `check_tbl_col_types()` where columns in model output data with more than one class were causing an EXEC error (#118). Thanks for the bug report @ruarai!

# hubValidations 0.6.1

* Changed file name header colour in `hub_validations` object `print()` method to make more visible on lighter backgrounds.
Expand Down
2 changes: 1 addition & 1 deletion R/check_tbl_col_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ check_tbl_col_types <- function(tbl, file_path, hub_path,
tbl_types <- purrr::map_chr(tbl, ~ if (inherits(.x, "numeric")) {
typeof(.x)
} else {
class(.x)
paste(class(.x), collapse = "/")
})
compare_types <- schema == tbl_types

Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/_snaps/check_tbl_col_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@
Message:
Column data types match hub schema.

# check_tbl_col_types on datetimes doesn't cause exec error

Code
check_tbl_col_types(tbl, file_path, hub_path)
Output
<error/check_failure>
Error:
! Column data types do not match hub schema. `origin_date` should be "Date" not "POSIXct/POSIXt".

12 changes: 12 additions & 0 deletions tests/testthat/test-check_tbl_col_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,15 @@ test_that(
)
}
)

test_that("check_tbl_col_types on datetimes doesn't cause exec error", {
hub_path <- system.file("testhubs/simple", package = "hubValidations")
file_path <- "team1-goodmodel/2022-10-08-team1-goodmodel.csv"
tbl <- read_model_out_file(file_path, hub_path)
tbl$origin_date <- as.POSIXct(tbl$origin_date)

# Should return a check_failure not an exec error
expect_snapshot(
check_tbl_col_types(tbl, file_path, hub_path)
)
})

0 comments on commit 640f680

Please sign in to comment.