-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from frictionlessdata/cli_schema
Use CLI for schema-related tests
- Loading branch information
Showing
13 changed files
with
209 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#' Check data | ||
#' | ||
#' Check if an object is a non-empty data frame. | ||
#' | ||
#' @param data A data frame. | ||
#' @return `TRUE` or error. | ||
#' @family check functions | ||
#' @noRd | ||
check_data <- function(data) { | ||
if ( | ||
!is.data.frame(data) || | ||
replace_null(dim(data)[1], 0) == 0 || | ||
replace_null(dim(data)[2], 0) == 0 | ||
) { | ||
cli::cli_abort( | ||
"{.arg data} must be a data frame containing data.", | ||
class = "frictionless_error_data_invalid" | ||
) | ||
} | ||
|
||
return(TRUE) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
test_that("check_data() returns error on invalid or empty data frame", { | ||
expect_error( | ||
check_data("not_a_df"), | ||
class = "frictionless_error_data_invalid" | ||
) | ||
expect_error( | ||
check_data(data.frame()), | ||
class = "frictionless_error_data_invalid" | ||
) | ||
expect_error( | ||
check_data(data.frame("col_1" = character(0))), | ||
class = "frictionless_error_data_invalid" | ||
) | ||
expect_error( | ||
create_schema("not_a_df"), | ||
regexp = "`data` must be a data frame containing data.", | ||
fixed = TRUE | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.