diff --git a/tests/testthat/_snaps/learn.md b/tests/testthat/_snaps/learn.md new file mode 100644 index 0000000000..065e3c5b2d --- /dev/null +++ b/tests/testthat/_snaps/learn.md @@ -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) + diff --git a/tests/testthat/test-learn.R b/tests/testthat/test-learn.R index 0a5a4b146d..1a617e5598 100644 --- a/tests/testthat/test-learn.R +++ b/tests/testthat/test-learn.R @@ -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")) + }) +})