|
13 | 13 | import crypt
|
14 | 14 | import datetime
|
15 | 15 | import os
|
| 16 | +from unittest import mock |
16 | 17 | import re
|
17 | 18 | import time
|
18 | 19 | from ipaddress import IPv4Address, IPv6Address, ip_address
|
@@ -59,15 +60,18 @@ def test_held_package(host):
|
59 | 60 | assert python.version.startswith("3.11.")
|
60 | 61 |
|
61 | 62 | @pytest.mark.testinfra_hosts("docker://rockylinux9")
|
62 |
| -def test_rpm_package_not_installed(host): |
63 |
| - # Pass an invalid value as package name, it returns exit code 1 |
64 |
| - pkg_name = "-3" |
65 |
| - with pytest.raises(RuntimeError) as excinfo: |
66 |
| - host.package(pkg_name).is_installed |
67 |
| - assert ( |
68 |
| - f"Could not check if RPM package '{pkg_name}' is installed. " |
69 |
| - f"rpm: {pkg_name}: unknown option" |
70 |
| - ) in str(excinfo.value) |
| 63 | +def test_rpmdb_corrupted(host): |
| 64 | + host.check_output("mv /var/lib/rpm/rpmdb.sqlite /var/lib/rpm/rpmdb.sqlite.bck") |
| 65 | + try: |
| 66 | + host.check_output("dd if=/dev/zero of=/var/lib/rpm/rpmdb.sqlite bs=1024 count=1") |
| 67 | + with pytest.raises(RuntimeError) as excinfo: |
| 68 | + host.package("zsh").is_installed |
| 69 | + assert ( |
| 70 | + f"Could not check if RPM package 'zsh' is installed. " |
| 71 | + "error: sqlite failure:" |
| 72 | + ) in str(excinfo.value) |
| 73 | + finally: |
| 74 | + host.check_output("mv /var/lib/rpm/rpmdb.sqlite.bck /var/lib/rpm/rpmdb.sqlite") |
71 | 75 |
|
72 | 76 | @pytest.mark.testinfra_hosts("docker://rockylinux9")
|
73 | 77 | def test_non_default_package_tool(host):
|
|
0 commit comments