File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3182,6 +3182,8 @@ def _run_janitor(
31823182 current_ts = now_timestamp ()
31833183 failures : t .List [str ] = []
31843184
3185+ self ._load_materializations ()
3186+
31853187 # Clean up expired environments by removing their views and schemas
31863188 failures .extend (
31873189 self ._cleanup_environments (
Original file line number Diff line number Diff line change @@ -86,6 +86,29 @@ def test_table_name(init_and_plan_context: t.Callable):
8686 )
8787
8888
89+ def test_janitor_loads_materialization (mocker : MockerFixture , tmp_path : Path ):
90+ models_dir = tmp_path / "models"
91+ models_dir .mkdir (exist_ok = True )
92+
93+ test_model = models_dir / "model.sql"
94+
95+ with open (test_model , "w" ) as f :
96+ f .write (
97+ "MODEL(name test.model, kind CUSTOM (materialization 'custom_full')); SELECT 1 AS col"
98+ )
99+
100+ config = Config (model_defaults = ModelDefaultsConfig (dialect = "duckdb" ))
101+ ctx = Context (paths = [tmp_path ], config = config )
102+ ctx .plan ("dev" , no_prompts = True , auto_apply = True )
103+
104+ load_materializations_spy = mocker .spy (Context , "_load_materializations" )
105+
106+ ctx .invalidate_environment ("dev" )
107+ ctx .run_janitor (ignore_ttl = True )
108+
109+ load_materializations_spy .assert_called_once ()
110+
111+
89112def test_janitor_cleanup_order (mocker : MockerFixture , tmp_path : Path ):
90113 def setup_scenario ():
91114 models_dir = tmp_path / "models"
You can’t perform that action at this time.
0 commit comments