Skip to content

Commit

Permalink
Update test to check Note event contents for total bad model names
Browse files Browse the repository at this point in the history
  • Loading branch information
QMalcolm committed Apr 10, 2024
1 parent dcd9b56 commit bb70e1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ def check_for_spaces_in_model_names(self):
)
improper_model_names += 1

# don't note the total of problematic names unless more than 1
if improper_model_names >= 2 and not self.root_project.args.DEBUG:
fire_event(
Note(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ def models(self) -> Dict[str, str]:

def tests_warning_when_spaces_in_name(self, project) -> None:
event_catcher = EventCatcher(SpacesInModelNameDeprecation)
runner = dbtRunner(callbacks=[event_catcher.catch])
note_catcher = EventCatcher(Note)
runner = dbtRunner(callbacks=[event_catcher.catch, note_catcher.catch])
runner.invoke(["parse"])

assert len(note_catcher.caught_events) == 0
assert len(event_catcher.caught_events) == 1
event = event_catcher.caught_events[0]
assert "Model `my model` has spaces in its name. This is deprecated" in event.info.msg
Expand All @@ -60,6 +62,9 @@ def tests_debug_when_spaces_in_name(self, project) -> None:
runner.invoke(["parse"])
assert len(spaces_check_catcher.caught_events) == 1
assert len(note_catcher.caught_events) == 1
assert (
"Found 2 models with spaces in their names" in note_catcher.caught_events[0].info.msg
)

spaces_check_catcher = EventCatcher(SpacesInModelNameDeprecation)
note_catcher = EventCatcher(Note)
Expand Down

0 comments on commit bb70e1e

Please sign in to comment.