Modified assert module to take tests as an array

pull/6073/head
James Cammarata 11 years ago
parent bee089d5e1
commit 54117ab28f

@ -46,11 +46,12 @@ class ActionModule(object):
if not 'that' in args: if not 'that' in args:
raise errors.AnsibleError('conditional required in "that" string') raise errors.AnsibleError('conditional required in "that" string')
result = utils.check_conditional(args['that'], self.runner.basedir, inject, fail_on_undefined=True) if not isinstance(args['that'], list):
args['that'] = [ args['that'] ]
if not result: for that in args['that']:
result = dict(failed=True, assertion=args['that'], evaluated_to=result) result = utils.check_conditional(args['that'], self.runner.basedir, inject, fail_on_undefined=True)
else: if not result:
result = dict(msg='ok', assertion=args['that'], evaluated_to=result) return ReturnData(conn=conn, result=dict(failed=True, assertion=that, evaluated_to=result))
return ReturnData(conn=conn, result=result) return ReturnData(conn=conn, result=dict(msg='all assertions passed'))

@ -22,16 +22,19 @@
copy: src=foo.txt dest={{output_file}} copy: src=foo.txt dest={{output_file}}
register: copy_result register: copy_result
- assert: { that: "'changed' in copy_result" } - name: assert basic copy worked
- assert: { that: "'dest' in copy_result" } assert:
- assert: { that: "'group' in copy_result" } that:
- assert: { that: "'gid' in copy_result" } - "'changed' in copy_result"
- assert: { that: "'md5sum' in copy_result" } - "'dest' in copy_result"
- assert: { that: "'owner' in copy_result" } - "'group' in copy_result"
- assert: { that: "'size' in copy_result" } - "'gid' in copy_result"
- assert: { that: "'src' in copy_result" } - "'md5sum' in copy_result"
- assert: { that: "'state' in copy_result" } - "'owner' in copy_result"
- assert: { that: "'uid' in copy_result" } - "'size' in copy_result"
- "'src' in copy_result"
- "'state' in copy_result"
- "'uid' in copy_result"
- name: verify that the file was marked as changed - name: verify that the file was marked as changed

Loading…
Cancel
Save