From 21ebed9305e8bc0e4dde86fa7b6999afc3e616d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Tue, 20 Feb 2024 12:13:07 +0100 Subject: [PATCH] Add unit test for org.osbuild.grub2.legacy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For now, test the content of /etc/default/grub configuration file. Signed-off-by: Tomáš Hozza --- stages/test/test_grub2_legacy.py | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 stages/test/test_grub2_legacy.py diff --git a/stages/test/test_grub2_legacy.py b/stages/test/test_grub2_legacy.py new file mode 100644 index 00000000..455188c2 --- /dev/null +++ b/stages/test/test_grub2_legacy.py @@ -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 +"""