Skip to content

Commit

Permalink
Add snapshot test
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed May 28, 2022
1 parent 5119330 commit 424701b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
40 changes: 40 additions & 0 deletions tests/testthat/_snaps/learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# dm_meta() data model

Code
dm_meta(my_test_src()) %>% dm_paste(options = c("select", "keys", "color"))
Message
dm::dm(
schemata,
tables,
columns,
table_constraints,
key_column_usage,
constraint_column_usage,
) %>%
dm::dm_select(schemata, catalog_name, schema_name) %>%
dm::dm_select(tables, table_catalog, table_schema, table_name, table_type) %>%
dm::dm_select(columns, table_catalog, table_schema, table_name, column_name, ordinal_position, column_default, is_nullable) %>%
dm::dm_select(table_constraints, constraint_catalog, constraint_schema, constraint_name, table_catalog, table_schema, table_name, constraint_type) %>%
dm::dm_select(key_column_usage, constraint_catalog, constraint_schema, constraint_name, table_catalog, table_schema, table_name, column_name, ordinal_position) %>%
dm::dm_select(constraint_column_usage, table_catalog, table_schema, table_name, column_name, constraint_catalog, constraint_schema, constraint_name, ordinal_position) %>%
dm::dm_add_pk(schemata, c(catalog_name, schema_name)) %>%
dm::dm_add_pk(tables, c(table_catalog, table_schema, table_name)) %>%
dm::dm_add_pk(columns, c(table_catalog, table_schema, table_name, column_name)) %>%
dm::dm_add_pk(table_constraints, c(constraint_catalog, constraint_schema, constraint_name)) %>%
dm::dm_add_pk(key_column_usage, c(constraint_catalog, constraint_schema, constraint_name, ordinal_position)) %>%
dm::dm_add_pk(constraint_column_usage, c(constraint_catalog, constraint_schema, constraint_name, ordinal_position)) %>%
dm::dm_add_fk(tables, c(table_catalog, table_schema), schemata) %>%
dm::dm_add_fk(columns, c(table_catalog, table_schema, table_name), tables) %>%
dm::dm_add_fk(table_constraints, c(table_catalog, table_schema, table_name), tables) %>%
dm::dm_add_fk(key_column_usage, c(table_catalog, table_schema, table_name, column_name), columns) %>%
dm::dm_add_fk(constraint_column_usage, c(table_catalog, table_schema, table_name, column_name), columns) %>%
dm::dm_add_fk(key_column_usage, c(constraint_catalog, constraint_schema, constraint_name), table_constraints) %>%
dm::dm_add_fk(constraint_column_usage, c(constraint_catalog, constraint_schema, constraint_name), table_constraints) %>%
dm::dm_add_fk(constraint_column_usage, c(constraint_catalog, constraint_schema, constraint_name, ordinal_position), key_column_usage) %>%
dm::dm_set_colors(`#0000FFFF` = schemata) %>%
dm::dm_set_colors(`#A52A2AFF` = tables) %>%
dm::dm_set_colors(`#A52A2AFF` = columns) %>%
dm::dm_set_colors(`#008B00FF` = table_constraints) %>%
dm::dm_set_colors(`#FFA500FF` = key_column_usage) %>%
dm::dm_set_colors(`#FFA500FF` = constraint_column_usage)

9 changes: 7 additions & 2 deletions tests/testthat/test-learn.R
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ test_that("Learning from a specific schema in another DB for MSSQL works?", {
)
})

# tests for compound keys -------------------------------------------------
test_that("dm_meta() data model", {
skip_if_src_not("mssql")

# test is already done in test-dm-from-src.R
expect_snapshot({
dm_meta(my_test_src()) %>%
dm_paste(options = c("select", "keys", "color"))
})
})

0 comments on commit 424701b

Please sign in to comment.