Cover the example configs with a parsing test

Nothing in the test suite or CI reads examples/, which is how the sample
config could stay broken for years while every other config surface kept
working. Parse both example files through ArchConfigHandler, and check
the partition entries directly since the parser only reaches them when
the configured device exists on the machine, which is never true in CI.
This commit is contained in:
Victor 2026-08-06 20:25:22 -03:00
parent df9c37ad93
commit ed47743186
2 changed files with 59 additions and 1 deletions

View File

@ -8,6 +8,16 @@ def config_fixture() -> Path:
return Path(__file__).parent / 'data' / 'test_config.json'
@pytest.fixture(scope='session')
def example_config_fixture() -> Path:
return Path(__file__).parent.parent / 'examples' / 'config-sample.json'
@pytest.fixture(scope='session')
def example_creds_fixture() -> Path:
return Path(__file__).parent.parent / 'examples' / 'creds-sample.json'
@pytest.fixture(scope='session')
def btrfs_config_fixture() -> Path:
return Path(__file__).parent / 'data' / 'test_config_btrfs.json'

View File

@ -1,3 +1,4 @@
import json
import os
from importlib.metadata import version
from pathlib import Path
@ -17,7 +18,7 @@ from archinstall.lib.models.application import (
)
from archinstall.lib.models.authentication import AuthenticationConfiguration, U2FLoginConfiguration, U2FLoginMethod
from archinstall.lib.models.bootloader import Bootloader, BootloaderConfiguration
from archinstall.lib.models.device import DiskLayoutConfiguration, DiskLayoutType
from archinstall.lib.models.device import DiskLayoutConfiguration, DiskLayoutType, Size
from archinstall.lib.models.locale import LocaleConfiguration
from archinstall.lib.models.mirrors import CustomRepository, CustomServer, MirrorConfiguration, MirrorRegion, SignCheck, SignOption
from archinstall.lib.models.network import NetworkConfiguration, Nic, NicType
@ -388,3 +389,50 @@ def test_encrypted_creds_with_env_var(
groups=[],
),
]
def test_example_config_parsing(
monkeypatch: MonkeyPatch,
example_config_fixture: Path,
example_creds_fixture: Path,
) -> None:
monkeypatch.setattr(
'sys.argv',
[
'archinstall',
'--config',
str(example_config_fixture),
'--creds',
str(example_creds_fixture),
],
)
handler = ArchConfigHandler()
arch_config = handler.config
assert arch_config.disk_config is not None
assert arch_config.profile_config is not None
assert arch_config.auth_config is not None
assert arch_config.auth_config.users
def test_example_config_partitions(example_config_fixture: Path) -> None:
# partition entries are only parsed when the configured device is present on
# the machine, which is never the case in CI, so read them here directly
config = json.loads(example_config_fixture.read_text())
for device in config['disk_config']['device_modifications']:
previous_end = None
for partition in device['partitions']:
assert 'dev_path' in partition
start = Size.parse_args(partition['start'])
end = start + Size.parse_args(partition['size'])
assert start.is_valid_start()
if previous_end is not None:
assert start >= previous_end
previous_end = end