Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 make a unit test #22

Merged
merged 6 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Imports: stats,
Suggests: tibble,
knitr,
dplyr,
ggplot2
VignetteBuilder: knitr
ggplot2, tinytest
VignetteBuilder: knitr
22 changes: 15 additions & 7 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,26 @@ navbar:
reference:

- title: Synthetic Relational Data Framework
desc: This package provides a general framework and utility functions for simulating or synthesizing database-like multiple-table datasets
desc: General framework functions for simulating or synthesizing database-like multiple-table datasets
contents:
- gen_reljoin_table
- gen_table_data
- inject_nas
- no_key
- table_spec
- validate_recipe_deps

- title: Internal Functions
desc:
contents:
- lookup_fun

- title: Helper Functions
desc:
contents:
- inject_nas
- miss_as_block
- miss_at_random
- rand_atm
- pct_orig
- reljoin_funcs
- samps
- sentinelS
- sample_fct
- subjid_func
- table_sepc
- validate_recipe_deps
28 changes: 28 additions & 0 deletions inst/tinytest/test_respectables.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

library(tinytest)
library(tibble)
library(respectables)

noop_fun <- respectables:::noop_func_constr("INDEP")

badrec1 <- tibble(variables = "MISSINGDEP", dependencies = "MISSING", func = list(function(n, .df, ...) rep("", n)), func_args = list(NULL))
expect_error(validate_recipe_deps(badrec1), "No independent recipe components found")



badrec2 <- tribble(~variables, ~dependencies, ~func, ~func_args,
"INDEP", no_deps, noop_fun, NULL,
"CDEP1", "CDEP2", noop_fun, NULL,
"CDEP2", "CDEP1", noop_fun, NULL)

expect_error(validate_recipe_deps(badrec2), "Unable to generate some dependent variables: CDEP1, CDEP2")


badrec3 <- tibble(variables = list("REAL", character()), list(noop_fun, noop_fun), list(NULL, NULL))
badrec4 <- rbind(badrec3[1,], badrec3[1,])
expect_error(validate_recipe_deps(badrec4), "Repeated variable")


result_id <- subjid_func(5, prefix = "p", suffix = "x")[4]
expect_id <- "p-4-x"
expect_identical(result_id, expect_id)
26 changes: 0 additions & 26 deletions tests/tests.R

This file was deleted.

5 changes: 5 additions & 0 deletions tests/tinytest.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

if ( requireNamespace("tinytest", quietly=TRUE) ){
tinytest::test_package("respectables")
}