Skip to content

Commit

Permalink
Improve tarball package test naming and add related unhappy path test
Browse files Browse the repository at this point in the history
  • Loading branch information
QMalcolm committed Nov 14, 2023
1 parent d93c523 commit 6d68e78
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tests/functional/dependencies/test_simple_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down Expand Up @@ -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

0 comments on commit 6d68e78

Please sign in to comment.