Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_patch(changedir, tmpdir):
tdir = str(tmpdir.mkdir('test_patch'))
shutil.rmtree(tdir, ignore_errors=True)
shutil.copytree('tests/test_patch', tdir)
os.chdir(tdir)
kas.kas(['shell', 'test.yml', '-c', 'true'])
for f in ['kas/tests/test_patch/hello.sh', 'hello/hello.sh']:
assert os.stat(f)[stat.ST_MODE] & stat.S_IXUSR
kas.kas(['shell', 'test.yml', '-c', 'true'])
kas.kas(['shell', 'test.yml', '-c', 'true'])
(rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas',
fail=False, liveupdate=False)
assert rc != 0
assert output.strip() == ''
(rc, output) = run_cmd(['git', 'rev-parse', '-q', 'HEAD'], cwd='kas',
fail=False, liveupdate=False)
assert rc == 0
assert output.strip() == '907816a5c4094b59a36aec12226e71c461c05b77'
(rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas2',
fail=False, liveupdate=False)
assert rc == 0
assert output.strip() == 'refs/heads/master'
kas.kas(['shell', 'test2.yml', '-c', 'true'])
(rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas',
fail=False, liveupdate=False)
assert rc == 0
assert output.strip() == 'refs/heads/master'
(rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas2',
fail=False, liveupdate=False)
assert rc != 0
assert output.strip() == ''
(rc, output) = run_cmd(['git', 'rev-parse', '-q', 'HEAD'], cwd='kas2',
fail=False, liveupdate=False)
assert rc == 0
assert output.strip() == '907816a5c4094b59a36aec12226e71c461c05b77'
def test_refspec_switch(changedir, tmpdir):
"""
Test that the local git clone is correctly updated when switching
between a commit hash refspec and a branch refspec.
"""
tdir = str(tmpdir.mkdir('test_refspec_switch'))
shutil.rmtree(tdir, ignore_errors=True)
shutil.copytree('tests/test_refspec', tdir)
os.chdir(tdir)
kas.kas(['shell', 'test.yml', '-c', 'true'])
(rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas',
fail=False, liveupdate=False)
assert rc != 0
assert output.strip() == ''
(rc, output) = run_cmd(['git', 'rev-parse', '-q', 'HEAD'], cwd='kas',
fail=False, liveupdate=False)
assert rc == 0
assert output.strip() == '907816a5c4094b59a36aec12226e71c461c05b77'
(rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas2',
fail=False, liveupdate=False)
assert rc == 0
assert output.strip() == 'refs/heads/master'
kas.kas(['shell', 'test2.yml', '-c', 'true'])
(rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas',
fail=False, liveupdate=False)
def test_patch(changedir, tmpdir):
tdir = str(tmpdir.mkdir('test_patch'))
shutil.rmtree(tdir, ignore_errors=True)
shutil.copytree('tests/test_patch', tdir)
os.chdir(tdir)
kas.kas(['shell', 'test.yml', '-c', 'true'])
for f in ['kas/tests/test_patch/hello.sh', 'hello/hello.sh']:
assert os.stat(f)[stat.ST_MODE] & stat.S_IXUSR
kas.kas(['shell', 'test.yml', '-c', 'true'])