prereq tests for issue #8235 (yaml without lists) and error message difference in no-list mode

This commit is contained in:
regilero 2013-11-25 12:46:02 +01:00
parent 8024df8404
commit 58bfbff843
3 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,7 @@
# will fail with 'Cannot extend ID Z (...) not part of the high state.'
# and not "The following requisites were not found" like in yaml list syntax
I:
cmd.run:
- name: echo I
- prereq:
cmd: Z

View file

@ -0,0 +1,27 @@
# B --+
# |
# C <-+ ----+
# |
# A <-------+
# runs after C
A:
cmd.run:
- name: echo A third
# is running in test mode before C
# C gets executed first if this states modify something
- prereq_in:
cmd: C
# runs before C
B:
cmd.run:
- name: echo B first
# will test C and be applied only if C changes,
# and then will run before C
- prereq:
cmd: C
C:
cmd.run:
- name: echo C second

View file

@ -676,6 +676,22 @@ fi
}
self.assertEqual(expected_result_simple, result)
# same test, but not using lists in yaml syntax
# TODO: issue #8235, prereq ignored when not used in list syntax
# Currently fails badly with :
# TypeError encountered executing state.sls: string indices must be integers, not str.
#result={}
#expected_result_simple.pop('cmd_|-I_|-echo I_|-run')
#expected_result_simple.pop('cmd_|-J_|-echo J_|-run')
#ret = self.run_function('state.sls', mods='requisites.prereq_simple_nolist')
#for item,descr in ret.iteritems():
# result[item] = {
# '__run_num__': descr['__run_num__'],
# 'comment':descr['comment'],
# 'result':descr['result']
# }
#self.assertEqual(expected_result_simple, result)
result={}
ret = self.run_function('state.sls', mods='requisites.prereq_simple2')
for item,descr in ret.iteritems():
@ -686,6 +702,13 @@ fi
}
self.assertEqual(expected_result_simple2, result)
ret = self.run_function('state.sls', mods='requisites.prereq_error_nolist')
self.assertEqual(
ret,
['Cannot extend ID Z in "base:requisites.prereq_error_nolist".'
+ ' It is not part of the high state.']
)
ret = self.run_function('state.sls', mods='requisites.prereq_compile_error1')
self.assertEqual(
ret['cmd_|-B_|-echo B_|-run']['comment'],