Repository navigation
Commit 7e908ac
authored
fix(test): resolve mocked and expected-row references consistently in SQL tests (#1023)
* fix(test): resolve mocked and expected-row references consistently in SQL tests
A mocked name now always means the mock in every SQL-test CTE: an assertion
calling __ref() on a mocked model reads the mock instead of running the real
model, and mocked models no longer count as test targets. References written
directly in __expected__ CTEs are resolved like assertions and helpers.
Compile reports unmocked __source(), __seed() and __dbt_ref() calls and unknown
models in expected rows with P013. The native planner computes the models
helpers and expected rows read itself and rejects any reference left raw.
* fix(test): reject SQL tests whose checks read only mocks
A model-mode SQL test whose expected rows and assertions read only mocked names
runs no model and used to be skipped silently. Compile now reports it with a
located P013 diagnostic showing how to call __ref() on the model under test.
Macro, UDF and table-function tests and scenarios keep their own targets.
* fix(test): plan SQL-test helpers from the compiler's reads and clarify mock-only errors
The native planner now takes the helpers a test reads and the models its
expected rows and helpers reference from the compiler, fails when a request
omits them, and leaves unread helpers that call references out of the test
query, so a helper named like a column no longer runs or fails a test. A
reference the planner still cannot resolve is a located P013 instead of an
unlocated P001. The error for a test that mocks the model it tests now
explains how to mock the model's inputs instead.
* fix(test): satisfy the manual_contains lint in mocked reference checks1 parent a281c0d commit 7e908ac
24 files changed
Lines changed: 1612 additions & 299 deletions
File tree
- crates/sqlbuild-analysis/src/compiler
- _helpers/sql_tests
- tests
- scripts/compiler_differential/_helpers/corpus
- src/sqlbuild
- .agents/skills/sqlbuild/references/docs/concepts
- cli/commands/_helpers
- compile
- refactor
- compiler
- compile
- _helpers
- assembly
- attachment
- sql_tests
- classes
- planner/_helpers/sql_tests
- tests
- e2e/src/sqlbuild/cli/commands/main/test
- integration/src/sqlbuild/compiler/attachments
- unit/src/sqlbuild/compiler
- compile/_helpers
- planner/_helpers/sql_test_assembly
- website/src/content/docs/docs/concepts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
| 85 | + | |
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
| |||
160 | 163 | | |
161 | 164 | | |
162 | 165 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
170 | 177 | | |
171 | 178 | | |
172 | 179 | | |
| |||
176 | 183 | | |
177 | 184 | | |
178 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
179 | 189 | | |
180 | 190 | | |
181 | 191 | | |
| |||
294 | 304 | | |
295 | 305 | | |
296 | 306 | | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
327 | 313 | | |
328 | 314 | | |
329 | 315 | | |
| |||
344 | 330 | | |
345 | 331 | | |
346 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
347 | 338 | | |
348 | 339 | | |
349 | 340 | | |
| |||
549 | 540 | | |
550 | 541 | | |
551 | 542 | | |
552 | | - | |
| 543 | + | |
553 | 544 | | |
554 | 545 | | |
555 | 546 | | |
556 | 547 | | |
557 | 548 | | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | 549 | | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
| 550 | + | |
576 | 551 | | |
577 | 552 | | |
578 | 553 | | |
579 | 554 | | |
580 | | - | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
581 | 558 | | |
582 | 559 | | |
583 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
0 commit comments