test: add small test for argument parsing

This is just a small detail, but in some way CLI options are similar
to public API. I did this while trying some changes, even if in the
end the issue to solve was not in pmbootstrap, I thought it'd make
sense to contribute this.

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2626
This commit is contained in:
Pablo Correa Gómez 2025-06-14 22:54:41 +02:00 committed by Stefan Hansson
parent ed396475f5
commit 7d36c604f1
No known key found for this signature in database
GPG key ID: ACD854892B38D898

View file

@ -0,0 +1,19 @@
# Copyright 2025 Pablo Correa Gomez
# SPDX-License-Identifier: GPL-3.0-or-later
from pmb.parse import get_parser
def test_chroot_simple():
parser = get_parser()
args = parser.parse_args("chroot ls".split())
assert args.action == "chroot"
assert args.command == ["ls"]
def test_chroot_args():
parser = get_parser()
args = parser.parse_args("chroot --rootfs -- ls -l".split())
assert args.action == "chroot"
assert args.rootfs is True
assert args.command == ["ls", "-l"]