tests: Compensate fall-outs from commit/branch switch

As both test_dump and test_lockfile use the kas repo via its master
branch, they were now affected by master using the new syntax from some
of the test patterns. Account for that by checking the new property in
test_dump and by using a past commit with the new syntax in
test_lockfile.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Jan Kiszka 2023-06-18 23:04:34 +02:00
parent 7f91df6492
commit 65196e1933

View File

@ -99,7 +99,7 @@ def test_dump(changedir, tmpdir, capsys):
resolve = ['', '--resolve-refs', '--resolve-env'] resolve = ['', '--resolve-refs', '--resolve-env']
# test cross-product of these options (formats x resolve) # test cross-product of these options (formats x resolve)
for f, r in ((f, r) for f in formats for r in resolve): for f, r in ((f, r) for f in formats for r in resolve):
outfile = 'test_flat.%s' % f outfile = 'test_flat%s.%s' % (r, f)
if r == '--resolve-env': if r == '--resolve-env':
os.environ['TESTVAR_FOO'] = 'KAS' os.environ['TESTVAR_FOO'] = 'KAS'
@ -113,12 +113,12 @@ def test_dump(changedir, tmpdir, capsys):
with open(outfile, 'r') as cf: with open(outfile, 'r') as cf:
flatconf = json.load(cf) if f == 'json' else yaml.safe_load(cf) flatconf = json.load(cf) if f == 'json' else yaml.safe_load(cf)
refspec = flatconf['repos']['kas3'].get('refspec', None) commit = flatconf['repos']['kas3'].get('commit', None)
envvar = flatconf['env']['TESTVAR_FOO'] envvar = flatconf['env']['TESTVAR_FOO']
if r == '--resolve-refs': if r == '--resolve-refs':
assert refspec != 'master' assert commit is not None
else: else:
assert refspec == 'master' assert commit is None
if r == '--resolve-env': if r == '--resolve-env':
assert envvar == 'KAS' assert envvar == 'KAS'
else: else:
@ -156,8 +156,8 @@ def test_lockfile(changedir, tmpdir, capsys):
assert lockspec['overrides']['repos']['externalrepo']['commit'] \ assert lockspec['overrides']['repos']['externalrepo']['commit'] \
== expected_commit == expected_commit
# insert older commit into lockfile (kas 3.2 tag) # insert older commit into lockfile (kas post commit/branch introduction)
test_commit = 'dc44638cd87c4d0045ea2ca441e682f3525d8b91' test_commit = '226e92a7f30667326a63fd9812b8cc4a6184e398'
lockspec['overrides']['repos']['externalrepo']['commit'] = test_commit lockspec['overrides']['repos']['externalrepo']['commit'] = test_commit
with open('test.lock.yml', 'w') as f: with open('test.lock.yml', 'w') as f:
yaml.safe_dump(lockspec, f) yaml.safe_dump(lockspec, f)