@@ -80,6 +80,47 @@ def test_run_seed_test(self, project):
8080 check_relations_equal (project .adapter , ["seed" , "materialization" ])
8181
8282
83+ class TestOnTableExistsSkip (BaseOnTableExists ):
84+ """
85+ Testing on_table_exists = `skip` configuration for table materialization,
86+ using dbt seed, run and tests commands and validate data load correctness.
87+ """
88+
89+ @pytest .fixture (scope = "class" )
90+ def project_config_update (self ):
91+ return {
92+ "name" : "table_rename" ,
93+ "models" : {"+materialized" : "table" , "+on_table_exists" : "skip" },
94+ "seeds" : {
95+ "+column_types" : {"some_date" : "timestamp(6)" },
96+ },
97+ }
98+
99+ # The actual sequence of dbt commands and assertions
100+ # pytest will take care of all "setup" + "teardown"
101+ def test_run_seed_test (self , project ):
102+ # seed seeds
103+ results = run_dbt (["seed" ], expect_pass = True )
104+ assert len (results ) == 1
105+ # run models two times to check on_table_exists = 'skip'
106+ results , logs = run_dbt_and_capture (["--debug" , "run" ], expect_pass = True )
107+ assert len (results ) == 1
108+ assert (
109+ f'create table "{ project .database } "."{ project .test_schema } "."materialization"' in logs
110+ )
111+ assert "alter table" not in logs
112+ results , logs = run_dbt_and_capture (["--debug" , "run" ], expect_pass = True )
113+ assert len (results ) == 1
114+ assert "drop table" not in logs
115+ assert "create table" not in logs
116+ # test tests
117+ results = run_dbt (["test" ], expect_pass = True )
118+ assert len (results ) == 3
119+
120+ # check if the data was loaded correctly
121+ check_relations_equal (project .adapter , ["seed" , "materialization" ])
122+
123+
83124class TestOnTableExistsRenameIncrementalFullRefresh (BaseOnTableExists ):
84125 """
85126 Testing on_table_exists = `rename` configuration for incremental materialization and full refresh flag,
0 commit comments