filter empty packages from database

In some cases (e.g. during addition of the package to build queue) we don't have
full information about package inself; in these cases we produce lines
with empty architecture, which duplicates normal ones.

This commit changes architecture column type to required and also
filters packages which don't have architecture set yet.

Closes #83
This commit is contained in:
2023-01-30 17:57:13 +02:00
parent 9d7f63e549
commit 0a2ba4ae07
4 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,8 @@
from ahriman.core.database.migrations.m006_packages_architecture_required import steps
def test_migration_logs() -> None:
"""
migration must not be empty
"""
assert steps

View File

@ -48,6 +48,16 @@ def test_package_update_insert_packages(database: SQLite, connection: Connection
connection.executemany(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int))
def test_package_update_insert_packages_no_arch(database: SQLite, connection: Connection,
package_ahriman: Package) -> None:
"""
must skip package insertion if no package architecture set
"""
package_ahriman.packages[package_ahriman.base].architecture = None
database._package_update_insert_packages(connection, package_ahriman)
connection.executemany(pytest.helpers.anyvar(str, strict=True), [])
def test_package_update_insert_status(database: SQLite, connection: Connection, package_ahriman: Package) -> None:
"""
must insert single package status