Skip to content

Commit

Permalink
allow single name tags in test configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Beck committed Jan 27, 2020
1 parent 5c80d6a commit 8b722c7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions core/dbt/parser/schema_test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ def severity(self) -> str:

def tags(self) -> List[str]:
tags = self.modifiers.get('tags', [])
if isinstance(tags, str):
tags = [tags]
if not isinstance(tags, list):
raise_compiler_error(
f'got {tags} ({type(tags)}) for tags, expected a list of '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ models:
- name: favorite_color
description: "The user's favorite color"
tests:
- accepted_values: { values: ['blue', 'green'], quote: true }
- accepted_values: {
values: ['blue', 'green'],
quote: true,
tags: table_copy_favorite_color # tags can be a single string
}
tags:
- table_favorite_color
- name: fav_number
Expand All @@ -41,7 +45,7 @@ models:
- accepted_values:
values: [3.14159265]
quote: false
tags:
tags: # tags can be a list of strings
- favorite_number_is_pi


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def test_postgres_schema_test_selection(self):
self.assertEqual(len(test_results), 1)
self.assertTestPassed(test_results[0])

test_results = self.run_dbt(['test', '--models', 'tag:table_copy_favorite_color'])
self.assertEqual(len(test_results), 1)
self.assertTestPassed(test_results[0])


@use_profile('postgres')
def test_postgres_schema_test_exclude_failures(self):
results = self.run_dbt()
Expand Down

0 comments on commit 8b722c7

Please sign in to comment.