1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2026-03-02 03:49:29 +00:00

Support git-crypt (#168)

Support is inherently provided by `enter`, which now supports a command.
I've added a `git-crypt` command, which is really just an alias
under-the-hood for "enter git-crypt".
This commit is contained in:
Tim Byrne
2019-12-15 18:42:21 -06:00
parent b9f5fdaafa
commit d3a2a06184
3 changed files with 92 additions and 31 deletions

View File

@@ -89,6 +89,7 @@ def supported_commands():
'decrypt',
'encrypt',
'enter',
'git-crypt',
'gitconfig',
'help',
'init',

42
test/test_git_crypt.py Normal file
View File

@@ -0,0 +1,42 @@
"""Test git-crypt"""
import pytest
@pytest.mark.parametrize(
'crypt',
[False, 'installed', 'installed-but-failed'],
ids=['not-installed', 'installed', 'installed-but-failed']
)
def test_git_crypt(runner, yadm, paths, tmpdir, crypt):
"""git-crypt tests"""
paths.repo.ensure(dir=True)
bindir = tmpdir.mkdir('bin')
pgm = bindir.join('test-git-crypt')
if crypt:
pgm.write(f'#!/bin/sh\necho git-crypt ran\n')
pgm.chmod(0o775)
if crypt == 'installed-but-failed':
pgm.write('false\n', mode='a')
script = f"""
YADM_TEST=1 source {yadm}
YADM_REPO={paths.repo}
GIT_CRYPT_PROGRAM="{pgm}"
git_crypt "param1"
"""
run = runner(command=['bash'], inp=script)
if crypt:
if crypt == 'installed-but-failed':
assert run.failure
else:
assert run.success
assert run.out.strip() == 'git-crypt ran'
else:
assert run.failure
assert f"command '{pgm}' cannot be located" in run.out
assert run.err == ''