From d43194c0b3aaa04bd0030f217a7111ad356d1c48 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 7 Mar 2024 09:50:03 +0100 Subject: [PATCH] test: add unit-{type,path} test coverage --- stages/test/test_systemd_unit_create.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/stages/test/test_systemd_unit_create.py b/stages/test/test_systemd_unit_create.py index 74e05f48..b0f251e0 100644 --- a/stages/test/test_systemd_unit_create.py +++ b/stages/test/test_systemd_unit_create.py @@ -46,9 +46,17 @@ def test_schema_validation(stage_schema, test_data, expected_err): testutil.assert_jsonschema_error_contains(res, expected_err, expected_num_errs=1) -def test_systemd_unit_create_simple(tmp_path, stage_module): +@pytest.mark.parametrize("unit_type,unit_path,expected_prefix", [ + ("system", "usr", "usr/lib/systemd/system"), + ("system", "etc", "etc/systemd/system"), + ("global", "usr", "usr/lib/systemd/user"), + ("global", "etc", "etc/systemd/user"), +]) +def test_systemd_unit_create(tmp_path, stage_module, unit_type, unit_path, expected_prefix): options = { "filename": "create-directory.service", + "unit-type": unit_type, + "unit-path": unit_path, "config": { "Unit": { "Description": "Create directory", @@ -75,7 +83,7 @@ def test_systemd_unit_create_simple(tmp_path, stage_module): } } } - expected_unit_path = tmp_path / "usr/lib/systemd/system/create-directory.service" + expected_unit_path = tmp_path / expected_prefix / "create-directory.service" # should the stage create the dir? expected_unit_path.parent.mkdir(parents=True)