diff --git a/.changes/unreleased/Features-20240412-105245.yaml b/.changes/unreleased/Features-20240412-105245.yaml new file mode 100644 index 00000000..2712c277 --- /dev/null +++ b/.changes/unreleased/Features-20240412-105245.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Add `error_tag` util to the `ui` module +time: 2024-04-12T10:52:45.887334-07:00 +custom: + Author: QMalcolm + Issue: "107" diff --git a/dbt_common/ui.py b/dbt_common/ui.py index 291d5f06..15eeff0f 100644 --- a/dbt_common/ui.py +++ b/dbt_common/ui.py @@ -80,3 +80,7 @@ def line_wrap_message(msg: str, subtract: int = 0, dedent: bool = True, prefix: def warning_tag(msg: str) -> str: return f'[{yellow("WARNING")}]: {msg}' + + +def error_tag(msg: str) -> str: + return f'[{red("ERROR")}]: {msg}' diff --git a/tests/unit/test_ui.py b/tests/unit/test_ui.py new file mode 100644 index 00000000..22e431d5 --- /dev/null +++ b/tests/unit/test_ui.py @@ -0,0 +1,11 @@ +from dbt_common.ui import warning_tag, error_tag + + +def test_warning_tag(): + tagged = warning_tag("hi") + assert "WARNING" in tagged + + +def test_error_tag(): + tagged = error_tag("hi") + assert "ERROR" in tagged