Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sqlmesh/core/test/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@ def _validate_and_normalize_test(self) -> None:
query = outputs.get("query")
partial = outputs.pop("partial", None)

if ctes is None and query is None:
_raise_error("Incomplete test, outputs must contain 'query' or 'ctes'", self.path)

def _normalize_rows(
values: t.List[Row] | t.Dict,
name: str,
Expand Down
21 changes: 21 additions & 0 deletions tests/core/test_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,27 @@ def test_unknown_column_error() -> None:
)


def test_invalid_outputs_error() -> None:
with pytest.raises(TestError, match="Incomplete test, outputs must contain 'query' or 'ctes'"):
_create_test(
body=load_yaml(
"""
test_foo:
model: sushi.foo
inputs:
raw:
- id: 1
outputs:
rows:
- id: 1
"""
),
test_name="test_foo",
model=_create_model("SELECT id FROM raw"),
context=Context(config=Config(model_defaults=ModelDefaultsConfig(dialect="duckdb"))),
)


def test_empty_rows(sushi_context: Context) -> None:
_check_successful_or_raise(
_create_test(
Expand Down