Add unit test for org.osbuild.grub2.legacy

For now, test the content of /etc/default/grub configuration file.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2024-02-20 12:13:07 +01:00 committed by Tomáš Hozza
parent b131d3cf57
commit 21ebed9305

View file

@ -0,0 +1,38 @@
#!/usr/bin/python3
import os.path
STAGE_NAME = "org.osbuild.grub2.legacy"
# Test that the /etc/default/grub file is created with the correct content
def test_grub2_default_conf(tmp_path, stage_module):
treedir = tmp_path / "tree"
confpath = treedir / "etc/default/grub"
confpath.parent.mkdir(parents=True, exist_ok=True)
options = {
"rootfs": {
"label": "root"
},
"entries": [
{
"id": "fff",
"kernel": "4.18",
"product": {
"name": "Fedora",
"version": "40"
}
}
]
}
stage_module.main(treedir, options)
assert os.path.exists(confpath)
assert confpath.read_text() == """GRUB_TIMEOUT=0
GRUB_CMDLINE_LINUX=""
GRUB_DISABLE_SUBMENU=true
GRUB_DISABLE_RECOVERY=true
GRUB_TIMEOUT_STYLE=countdown
GRUB_DEFAULT=saved
"""