context("unit test for TableCleaner")
# TableCleaner -----------------------------------------------------------------
test_that("TableCleaner generates a profile for mtcars", {
.create_temp_folder()
# No input argument
expect_error(TableCleaner$new())
# Generate mtcars config file
expect_silent(TableCleaner$new(table = mtcars, path = .get_temp_dir()))
expect_file_exists(file.path(.get_temp_dir(), "mtcars.yml"))
# Load mtcars config file without regenerating it
expect_identical(TableCleaner$new(table = mtcars, path = .get_temp_dir())$table, mtcars)
})
test_that("TableCleaner cleans the corrupted mtcars table", {
.create_temp_folder()
set.seed(2115)
mtcars_corrupted <- .insert_na_at_random(mtcars)
TC <- TableCleaner$new(table = mtcars_corrupted, path = .get_temp_dir())
# Remove NAs
expect_false(TC$drop_rows_with_na()$table %>% is.na() %>% any())
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.