From 0f8538d3e312b3fe31db89a817f44d089300058d Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Tue, 13 Sep 2022 12:38:18 -0500 Subject: [PATCH] Create tests for underscores in distro/family --- test/test_unit_score_file.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/test_unit_score_file.py b/test/test_unit_score_file.py index a63246a..e59c128 100644 --- a/test/test_unit_score_file.py +++ b/test/test_unit_score_file.py @@ -315,3 +315,37 @@ def test_template_recording(runner, yadm, cmd_generated): assert run.success assert run.err == '' assert run.out.rstrip() == expected + + +def test_underscores_in_distro_and_family(runner, yadm): + """Test replacing spaces in distro / distro_family with underscores""" + local_distro = 'test distro' + local_distro_family = 'test family' + filenames = { + 'filename##distro.test distro': 1004, + 'filename##distro.test-distro': 0, + 'filename##distro.test_distro': 1004, + 'filename##distro_family.test family': 1008, + 'filename##distro_family.test-family': 0, + 'filename##distro_family.test_family': 1008, + } + + script = f""" + YADM_TEST=1 source {yadm} + score=0 + local_distro="{local_distro}" + local_distro_family="{local_distro_family}" + """ + expected = '' + for filename in filenames: + script += f""" + score_file "{filename}" + echo "{filename}" + echo "$score" + """ + expected += filename + '\n' + expected += str(filenames[filename]) + '\n' + run = runner(command=['bash'], inp=script) + assert run.success + assert run.err == '' + assert run.out == expected