Default arguments from hooks.yaml

This commit is contained in:
Anthony Sottile 2015-01-12 09:35:05 -08:00
parent 78c682a1d1
commit 26502dfd0b
5 changed files with 13 additions and 2 deletions

View file

@ -30,7 +30,6 @@ CONFIG_JSON_SCHEMA = {
'language_version': {'type': 'string'}, 'language_version': {'type': 'string'},
'args': { 'args': {
'type': 'array', 'type': 'array',
'default': [],
'items': {'type': 'string'}, 'items': {'type': 'string'},
}, },
}, },

View file

@ -24,6 +24,13 @@ MANIFEST_JSON_SCHEMA = {
'language_version': {'type': 'string', 'default': 'default'}, 'language_version': {'type': 'string', 'default': 'default'},
'files': {'type': 'string'}, 'files': {'type': 'string'},
'expected_return_value': {'type': 'number', 'default': 0}, 'expected_return_value': {'type': 'number', 'default': 0},
'args': {
'type': 'array',
'default': [],
'items': {
'type': 'string',
},
},
}, },
'required': ['id', 'name', 'entry', 'language', 'files'], 'required': ['id', 'name', 'entry', 'language', 'files'],
}, },

View file

@ -3,3 +3,4 @@
entry: bin/hook.sh entry: bin/hook.sh
language: script language: script
files: '' files: ''
args: [hello, world]

View file

@ -19,6 +19,7 @@ def manifest(store, tmpdir_factory):
def test_manifest_contents(manifest): def test_manifest_contents(manifest):
# Should just retrieve the manifest contents # Should just retrieve the manifest contents
assert manifest.manifest_contents == [{ assert manifest.manifest_contents == [{
'args': [],
'description': '', 'description': '',
'entry': 'bin/hook.sh', 'entry': 'bin/hook.sh',
'expected_return_value': 0, 'expected_return_value': 0,
@ -32,6 +33,7 @@ def test_manifest_contents(manifest):
def test_hooks(manifest): def test_hooks(manifest):
assert manifest.hooks['bash_hook'] == { assert manifest.hooks['bash_hook'] == {
'args': [],
'description': '', 'description': '',
'entry': 'bin/hook.sh', 'entry': 'bin/hook.sh',
'expected_return_value': 0, 'expected_return_value': 0,

View file

@ -113,7 +113,9 @@ def test_run_a_script_hook(tmpdir_factory, store):
def test_run_hook_with_spaced_args(tmpdir_factory, store): def test_run_hook_with_spaced_args(tmpdir_factory, store):
_test_hook_repo( _test_hook_repo(
tmpdir_factory, store, 'arg_per_line_hooks_repo', tmpdir_factory, store, 'arg_per_line_hooks_repo',
'arg-per-line', ['foo bar', 'baz'], 'arg: foo bar\narg: baz\n', 'arg-per-line',
['foo bar', 'baz'],
'arg: hello\narg: world\narg: foo bar\narg: baz\n',
) )