From 33250866ec411da1d112decf2972fbc3958fee68 Mon Sep 17 00:00:00 2001 From: Felix Moessbauer Date: Sun, 11 Dec 2022 08:30:32 +0100 Subject: [PATCH] test dump plugin support for resolved refs This patch extends the test of the dump plugin. In addition, we test if relative refspecs are expanded and if the generated output can be used as input to kas again. Signed-off-by: Felix Moessbauer Signed-off-by: Jan Kiszka --- tests/test_commands.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index f557508..354526e 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -77,13 +77,25 @@ def test_dump(changedir, tmpdir, capsys): os.chdir(tdir) formats = ['json', 'yaml'] - for f in formats: + resolve = ['', '--resolve-refs'] + # test cross-product of these options (formats x resolve) + for f, r in ((f, r) for f in formats for r in resolve): outfile = 'test_flat.%s' % f - kas.kas(('dump --format %s test.yml' % f).split()) + kas.kas(('dump --format %s %s test.yml' % (f, r)).split()) with open(outfile, 'w') as f: f.write(capsys.readouterr().out) with open(outfile, 'r') as cf: flatconf = json.load(cf) if f == 'json' else yaml.safe_load(cf) - assert flatconf['repos']['kas3']['refspec'] == 'master' + refspec = flatconf['repos']['kas3']['refspec'] + if r == '--resolve-refs': + assert refspec != 'master' + else: + assert refspec == 'master' + assert 'includes' not in flatconf['header'] + # check if kas can read the generated file + if f == 'yaml': + shutil.rmtree('%s/build' % tdir, ignore_errors=True) + kas.kas(('checkout %s' % outfile).split()) + assert os.path.exists('build/conf/local.conf')