Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Beck committed Jun 10, 2020
1 parent a2de92d commit e2d7027
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions test/integration/024_custom_schema_test/test_custom_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,36 @@ def project_config(self):
},
}

def _list_schemas(self):
with self.get_connection():
return set(self.adapter.list_schemas(self.default_database))

def assert_schemas_created(self, expected):
assert self._list_schemas().intersection(expected) == expected

def assert_schemas_not_created(self, expected):
assert not self._list_schemas().intersection(expected)

@use_profile('postgres')
def test__postgres__custom_schema_with_prefix(self):
schema = self.unique_schema()
v1_schema = f"{schema}_dbt_test"
v2_schema = f"{schema}_custom"
xf_schema = f"{schema}_test"
new_schemas = {v1_schema, v2_schema, xf_schema}

self.assert_schemas_not_created(new_schemas)

self.run_sql_file("seed.sql")

self.run_dbt(['ls'])
self.assert_schemas_not_created(new_schemas)
self.run_dbt(['compile'])
self.assert_schemas_not_created(new_schemas)

results = self.run_dbt()
self.assertEqual(len(results), 3)

schema = self.unique_schema()
v1_schema = "{}_dbt_test".format(schema)
v2_schema = "{}_custom".format(schema)
xf_schema = "{}_test".format(schema)
self.assert_schemas_created(new_schemas)

self.assertTablesEqual("seed", "view_1", schema, v1_schema)
self.assertTablesEqual("seed", "view_2", schema, v2_schema)
Expand Down

0 comments on commit e2d7027

Please sign in to comment.