diff --git a/tests/functional/dependencies/test_simple_dependency.py b/tests/functional/dependencies/test_simple_dependency.py index 0a98c3d1a78..0c91c24e7d2 100644 --- a/tests/functional/dependencies/test_simple_dependency.py +++ b/tests/functional/dependencies/test_simple_dependency.py @@ -4,9 +4,11 @@ from pathlib import Path +from dbt.exceptions import DbtProjectError from dbt.tests.util import ( check_relations_equal, run_dbt, + write_config_file, ) @@ -392,5 +394,32 @@ def packages(self): ] } - def test_deps_tarball(self, project): + def test_deps_simple_tarball_doesnt_error_out(self, project): run_dbt(["deps"]) + assert len(os.listdir("dbt_packages")) == 1 + + +class TestBadTarballDependency(object): + @pytest.fixture(scope="class", autouse=True) + def setUp(self, project): + project.run_sql_file(project.test_data_dir / Path("seed.sql")) + + def test_malformed_tarball_package_causes_exception(self, project): + # We have to specify the bad formatted package here because if we do it + # in a `packages` fixture, the test will blow up in the setup phase, meaning + # we can't appropriately catch it with a `pytest.raises` + bad_tarball_package_spec = { + "packages": [ + { + "tarball": "https://codeload.github.com/dbt-labs/dbt-utils/tar.gz/0.9.6", + "version": "dbt_utils", + } + ] + } + write_config_file(bad_tarball_package_spec, "packages.yml") + + with pytest.raises( + DbtProjectError, match=r"The packages.yml file in this project is malformed" + ) as e: + run_dbt(["deps"]) + assert e is not None