You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ff50b02
Browse filesBrowse the repository at this point in the historyBrowse files
fix: require a TEST() header in SQL test files again
A SQL test file must again start with a TEST() header; a file without one
fails discovery with D003. Mode inference and the optional trailing
SELECT 1 are unchanged. Docs, the skill and the example tests show the
header again.
You can mock models directly with `__ref__<name>` and seeds with `__seed__<name>`, not just sources. This skips the model's real SQL (or the seed's real CSV data) and provides controlled data instead:
201
208
202
209
```sql
210
+
TEST();
211
+
203
212
WITH
204
213
__ref__stg_orders AS (
205
214
SELECT
@@ -270,6 +279,8 @@ expressions, with the fixture relation. The mocked function is not deployed as a
@@ -330,6 +343,8 @@ Only explicit expected CTEs create grants. A matching test filename, `__ref__` m
330
343
Because unit tests are written in SQL, they support macro calls. This lets you write reusable mock generators instead of copy-pasting mock data across test files:
331
344
332
345
```sql
346
+
TEST();
347
+
333
348
WITH
334
349
__source__raw__orders AS (
335
350
@mock_orders()
@@ -361,6 +376,8 @@ with `D013`.
361
376
When a model uses macros that you want to control in tests (e.g. target-specific logic, dynamic SQL generation), you can override their output with `__macro__<name>` CTEs:
362
377
363
378
```sql
379
+
TEST();
380
+
364
381
WITH
365
382
__macro__country_filter AS (
366
383
SELECT'country_code = ''US'''
@@ -387,6 +404,8 @@ This is useful for:
387
404
Unit tests can include `__assert__<name>` CTEs for property-based checks. An assertion passes if the query returns zero rows - any returned rows are failing examples.
0 commit comments