Skip to content

Commit

Permalink
[Backport 1.7.latest] Fix dbt deps failing on tarballs (#9075)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Nov 15, 2023
1 parent 7eb6cdb commit 67d8ce3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20231113-114956.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix formatting of tarball information in packages-lock.yml
time: 2023-11-13T11:49:56.437007-08:00
custom:
Author: ChenyuLInx QMalcolm
Issue: "9062"
3 changes: 1 addition & 2 deletions core/dbt/deps/tarball.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def name(self):
def to_dict(self) -> Dict[str, str]:
return {
"tarball": self.tarball,
"version": self.version,
"package": self.package,
"name": self.package,
}

def get_version(self):
Expand Down
41 changes: 41 additions & 0 deletions 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 @@ -374,3 +376,42 @@ def test_deps_bad_profile(self, project):
del os.environ["PROFILE_TEST_HOST"]
run_dbt(["deps"])
run_dbt(["clean"])


class TestSimpleDependcyTarball(object):
@pytest.fixture(scope="class")
def packages(self):
return {
"packages": [
{
"tarball": "https://codeload.github.com/dbt-labs/dbt-utils/tar.gz/0.9.6",
"name": "dbt_utils",
}
]
}

def test_deps_simple_tarball_doesnt_error_out(self, project):
run_dbt(["deps"])
assert len(os.listdir("dbt_packages")) == 1


class TestBadTarballDependency(object):
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 67d8ce3

Please sign in to comment.