Skip to content

Commit

Permalink
Add test for unit test list
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed Jan 29, 2024
1 parent 148974b commit 0f329b6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/dbt/parser/unit_tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from csv import DictReader
from copy import deepcopy
from pathlib import Path
from typing import List, Set, Dict, Any
import os
Expand Down Expand Up @@ -74,7 +75,7 @@ def parse_unit_test_case(self, test_case: UnitTestDefinition):
unique_id=test_case.unique_id,
config=UnitTestNodeConfig(
materialized="unit",
expected_rows=test_case.expect.rows, # type:ignore
expected_rows=deepcopy(test_case.expect.rows), # type:ignore
),
raw_code=tested_node.raw_code,
database=tested_node.database,
Expand Down
34 changes: 34 additions & 0 deletions tests/functional/unit_testing/test_ut_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pytest
from dbt.tests.util import run_dbt

from fixtures import ( # noqa: F401
my_model_vars_sql,
my_model_a_sql,
my_model_b_sql,
test_my_model_yml,
datetime_test,
)

class TestUnitTestList:
@pytest.fixture(scope="class")
def models(self):
return {
"my_model.sql": my_model_vars_sql,
"my_model_a.sql": my_model_a_sql,
"my_model_b.sql": my_model_b_sql,
"test_my_model.yml": test_my_model_yml + datetime_test,
}

@pytest.fixture(scope="class")
def project_config_update(self):
return {"vars": {"my_test": "my_test_var"}}

def test_unit_test_list(self, project):
# make sure things are working
results = run_dbt(["run"])
assert len(results) == 3
results = run_dbt(["test"], expect_pass=False)
assert len(results) == 5

results = run_dbt(["list"])

0 comments on commit 0f329b6

Please sign in to comment.