Skip to content

Commit

Permalink
integration tests for apt-get and apt-cache exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Perfect5th committed Dec 15, 2023
1 parent 2137e59 commit 06fe978
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/integration/test_apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ def test_install_package():
assert get_command_path("jq") == "/usr/bin/jq"


def test_install_package_error():
try:
package = apt.DebianPackage(
"ceci-n'est-pas-un-paquet",
"1.0",
"",
"amd64",
apt.PackageState.Available,
)
package.ensure(apt.PackageState.Present)
except apt.PackageError as e:
assert "Unable to locate package" in str(e)


def test_remove_package():
# First ensure the package is present
cfssl = apt.DebianPackage.from_apt_cache("golang-cfssl")
Expand Down Expand Up @@ -77,3 +91,10 @@ def test_list_file_generation_external_repository():
apt.add_package("mongodb-org")

assert get_command_path("mongod") == "/usr/bin/mongod"


def test_from_apt_cache_error():
try:
apt.DebianPackage.from_apt_cache("ceci-n'est-pas-un-paquet")
except apt.PackageError as e:
assert "No packages found" in str(e)

0 comments on commit 06fe978

Please sign in to comment.