Skip to content

Commit

Permalink
Add assertion to check media is not NULL
Browse files Browse the repository at this point in the history
This is needed to apply fail fast principle in get_record_table().
  • Loading branch information
damianooldoni committed Jul 17, 2023
1 parent e283f95 commit fda35af
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ check_package <- function(package = NULL,
assertthat::assert_that("data" %in% names(package))
# check validity data element of package: does it contain deployments and
# observations?
elements <- c("deployments", "observations") # media is typically not needed
if (isTRUE(media)) elements <- c(elements, "media")
elements <- c("deployments", "observations", "media")
tables_absent <- elements[
!elements %in% names(package$data)
]
Expand All @@ -45,6 +44,13 @@ check_package <- function(package = NULL,
.transformer = collapse_transformer(sep = ", ", last = " and ")
)
)

if (media == TRUE) {
assertthat::assert_that(
!is.null(package$data$media),
msg = glue::glue("Can't find media in .$data.")
)
}

# check observations and deployments are data.frames
assertthat::assert_that(is.data.frame(package$data$observations))
Expand Down

0 comments on commit fda35af

Please sign in to comment.