Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions examples/config-sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,27 @@
"partitions": [
{
"btrfs": [],
"dev_path": null,
"flags": [
"boot"
],
"fs_type": "fat32",
"size": {
"sector_size": null,
"sector_size": {
"unit": "B",
"value": 512
},
"unit": "MiB",
"value": 512
},
"mount_options": [],
"mountpoint": "/boot",
"obj_id": "2c3fa2d5-2c79-4fab-86ec-22d0ea1543c0",
"start": {
"sector_size": null,
"sector_size": {
"unit": "B",
"value": 512
},
"unit": "MiB",
"value": 1
},
Expand All @@ -39,18 +46,25 @@
},
{
"btrfs": [],
"dev_path": null,
"flags": [],
"fs_type": "ext4",
"size": {
"sector_size": null,
"sector_size": {
"unit": "B",
"value": 512
},
"unit": "GiB",
"value": 20
},
"mount_options": [],
"mountpoint": "/",
"obj_id": "3e7018a0-363b-4d05-ab83-8e82d13db208",
"start": {
"sector_size": null,
"sector_size": {
"unit": "B",
"value": 512
},
"unit": "MiB",
"value": 513
},
Expand All @@ -59,20 +73,27 @@
},
{
"btrfs": [],
"dev_path": null,
"flags": [],
"fs_type": "ext4",
"size": {
"sector_size": null,
"unit": "Percent",
"value": 100
"sector_size": {
"unit": "B",
"value": 512
},
"unit": "GiB",
"value": 10
},
"mount_options": [],
"mountpoint": "/home",
"obj_id": "ce58b139-f041-4a06-94da-1f8bad775d3f",
"start": {
"sector_size": null,
"unit": "GiB",
"value": 20
"sector_size": {
"unit": "B",
"value": 512
},
"unit": "MiB",
"value": 20993
},
"status": "create",
"type": "primary"
Expand Down Expand Up @@ -138,7 +159,7 @@
"parallel_downloads": 5
},
"profile_config": {
"gfx_driver": "All open-source (default)",
"gfx_driver": "All open-source",
"greeter": "sddm",
"profile": {
"details": [
Expand Down
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
57 changes: 56 additions & 1 deletion tests/test_args.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
from importlib.metadata import version
from pathlib import Path
Expand All @@ -17,7 +18,7 @@
)
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
Expand Down Expand Up @@ -388,3 +389,57 @@ 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())
device_modifications = config['disk_config']['device_modifications']

assert device_modifications

for device in device_modifications:
partitions = device['partitions']

assert partitions

previous_end = None

for partition in 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