1
0
Fork 0
mirror of synced 2024-12-12 18:35:46 -05:00

Test for escaped values in YADM_HOOK_FULL_COMMAND

This commit is contained in:
Tim Byrne 2020-01-24 08:33:30 -06:00
parent ccb75b97ea
commit 9a2883985b
No known key found for this signature in database
GPG key ID: 14DB4FC2465A4B12

View file

@ -103,6 +103,29 @@ def test_hook_env(runner, yadm_y, paths):
assert 'YADM_ENCRYPT_INCLUDE_FILES=a\nb\nc\n' in run.out assert 'YADM_ENCRYPT_INCLUDE_FILES=a\nb\nc\n' in run.out
def test_escaped(runner, yadm_y, paths):
"""Test escaped values in YADM_HOOK_FULL_COMMAND"""
# test will be done with a non existent "git" passthru command
# which should exit with a failing code
cmd = 'passthrucmd'
# write the hook
hook = paths.hooks.join(f'post_{cmd}')
hook.write('#!/bin/bash\nenv\n')
hook.chmod(0o755)
run = runner(yadm_y(cmd, 'a b', 'c\td', 'e\\f'))
# expect passthru to fail
assert run.failure
# verify escaped values
assert (
f'YADM_HOOK_FULL_COMMAND={cmd} '
'a\\ b c\\\td e\\\\f\n') in run.out
def create_hook(paths, name, code): def create_hook(paths, name, code):
"""Create hook""" """Create hook"""
hook = paths.hooks.join(name) hook = paths.hooks.join(name)