@@ -59,6 +59,31 @@ def create_example_project(temp_dir, template=ProjectTemplate.DEFAULT) -> None:
5959 )
6060
6161
62+ def add_unchanged_incremental_model_test (temp_dir ) -> None :
63+ with open (temp_dir / "tests" / "test_incremental_model.yaml" , "w" , encoding = "utf-8" ) as f :
64+ f .write (
65+ """
66+ test_example_incremental_model:
67+ model: sqlmesh_example.incremental_model
68+ vars:
69+ start: 2020-01-01
70+ end: 2020-01-02
71+ inputs:
72+ sqlmesh_example.seed_model:
73+ rows:
74+ - id: 1
75+ item_id: 1
76+ event_date: 2020-01-01
77+ outputs:
78+ query:
79+ rows:
80+ - id: 1
81+ item_id: 1
82+ event_date: 2020-01-01
83+ """
84+ )
85+
86+
6287def update_incremental_model (temp_dir ) -> None :
6388 with open (temp_dir / "models" / "incremental_model.sql" , "w" , encoding = "utf-8" ) as f :
6489 f .write (
@@ -117,7 +142,7 @@ def init_prod_and_backfill(runner, temp_dir) -> None:
117142
118143
119144def assert_duckdb_test (result ) -> None :
120- assert "Successfully Ran 2 tests against duckdb" in result .output
145+ assert "Successfully Ran 1 tests against duckdb" in result .output
121146
122147
123148def assert_new_env (result , new_env = "prod" , from_env = "prod" , initialize = True ) -> None :
@@ -188,7 +213,7 @@ def test_plan_skip_tests(runner, tmp_path):
188213 cli , ["--log-file-dir" , tmp_path , "--paths" , tmp_path , "plan" , "--skip-tests" ], input = "y\n "
189214 )
190215 assert result .exit_code == 0
191- assert "Successfully Ran 2 tests against duckdb" not in result .output
216+ assert "Successfully Ran 1 tests against duckdb" not in result .output
192217 assert_new_env (result )
193218 assert_backfill_success (result )
194219
@@ -201,7 +226,7 @@ def test_plan_no_changes_runs_tests_by_default(runner, tmp_path):
201226 cli , ["--log-file-dir" , tmp_path , "--paths" , tmp_path , "plan" , "--no-prompts" ], input = "\n "
202227 )
203228 assert result .exit_code == 0
204- assert "Successfully Ran 2 tests against duckdb" in result .output
229+ assert "Successfully Ran 1 tests against duckdb" in result .output
205230 assert "No changes to plan" in result .output or "No changes" in result .output
206231
207232
@@ -229,6 +254,7 @@ def test_plan_test_changed_only_with_no_changes(runner, tmp_path):
229254def test_plan_test_changed_only_runs_only_changed_model_tests (runner , tmp_path ):
230255 create_example_project (tmp_path )
231256 init_prod_and_backfill (runner , tmp_path )
257+ add_unchanged_incremental_model_test (tmp_path )
232258
233259 full_model_path = tmp_path / "models" / "full_model.sql"
234260 full_model_path .write_text (
@@ -256,14 +282,18 @@ def test_plan_test_changed_only_runs_only_changed_model_tests(runner, tmp_path):
256282def test_plan_select_model_test_changed_only_scopes_tests (runner , tmp_path ):
257283 create_example_project (tmp_path )
258284 init_prod_and_backfill (runner , tmp_path )
285+ add_unchanged_incremental_model_test (tmp_path )
259286
260287 full_model_path = tmp_path / "models" / "full_model.sql"
261288 full_model_path .write_text (
262289 full_model_path .read_text ().replace ("COUNT(DISTINCT id)" , "COUNT(id)" )
263290 )
264291 incremental_model_path = tmp_path / "models" / "incremental_model.sql"
265292 incremental_model_path .write_text (
266- incremental_model_path .read_text ().replace ("'a' as new_col," , "'b' as new_col," )
293+ incremental_model_path .read_text ().replace (
294+ " item_id,\n event_date," ,
295+ " item_id,\n 'b' as new_col,\n event_date," ,
296+ )
267297 )
268298
269299 result = runner .invoke (
@@ -355,7 +385,7 @@ def test_plan_skip_backfill(runner, tmp_path, flag):
355385 assert_virtual_layer_updated (result )
356386 assert "Model batches executed" not in result .output
357387 # Dry-run still runs plan-scoped unit tests
358- assert "Successfully Ran 2 tests against duckdb" in result .output
388+ assert "Successfully Ran 1 tests against duckdb" in result .output
359389
360390
361391def test_plan_min_intervals (runner , tmp_path ):
0 commit comments