add test for lockfile support
This commit adds a test that check the creation, effectiveness and update of a lockfile. Testing this functionality via the dump plugin is sufficient, as the plugin directly uses the checkout workflow. Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> [Jan: fix over-long lines and removed assert brackets] Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
7c0953c08e
commit
e2bf6d74df
@ -120,3 +120,44 @@ def test_dump(changedir, tmpdir, capsys):
|
||||
shutil.rmtree('%s/build' % tdir, ignore_errors=True)
|
||||
kas.kas(('checkout %s' % outfile).split())
|
||||
assert os.path.exists('build/conf/local.conf')
|
||||
|
||||
|
||||
def test_lockfile(changedir, tmpdir, capsys):
|
||||
tdir = str(tmpdir.mkdir('test_commands'))
|
||||
shutil.rmtree(tdir, ignore_errors=True)
|
||||
shutil.copytree('tests/test_repo_includes', tdir)
|
||||
os.chdir(tdir)
|
||||
|
||||
# no lockfile yet, branches are floating
|
||||
kas.kas('dump test.yml'.split())
|
||||
rawspec = yaml.safe_load(capsys.readouterr().out)
|
||||
assert rawspec['repos']['externalrepo']['refspec'] == 'master'
|
||||
|
||||
# create lockfile
|
||||
kas.kas('dump --lock --inplace test.yml'.split())
|
||||
assert os.path.exists('test.lock.yml')
|
||||
|
||||
# lockfile is considered during import, expect pinned branches
|
||||
kas.kas('dump test.yml'.split())
|
||||
lockspec = yaml.safe_load(capsys.readouterr().out)
|
||||
assert lockspec['overrides']['repos']['externalrepo']['refspec'] \
|
||||
!= 'master'
|
||||
|
||||
# insert older refspec into lockfile (kas 3.2 tag)
|
||||
test_refspec = 'dc44638cd87c4d0045ea2ca441e682f3525d8b91'
|
||||
lockspec['overrides']['repos']['externalrepo']['refspec'] = test_refspec
|
||||
with open('test.lock.yml', 'w') as f:
|
||||
yaml.safe_dump(lockspec, f)
|
||||
|
||||
# check if repo is moved to specified commit
|
||||
kas.kas('dump test.yml'.split())
|
||||
lockspec = yaml.safe_load(capsys.readouterr().out)
|
||||
assert lockspec['overrides']['repos']['externalrepo']['refspec'] \
|
||||
== test_refspec
|
||||
|
||||
# update lockfile, check if repo is pinned to other commit
|
||||
kas.kas('dump --lock --inplace --update test.yml'.split())
|
||||
with open('test.lock.yml', 'r') as f:
|
||||
lockspec = yaml.safe_load(f)
|
||||
assert lockspec['overrides']['repos']['externalrepo']['refspec'] \
|
||||
!= test_refspec
|
||||
|
Loading…
Reference in New Issue
Block a user