mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fixing a case where the state module would fail if the state file being passed was all integers. Added a new tests for this edge case.
This commit is contained in:
parent
e1dd10be70
commit
790801c67e
3 changed files with 22 additions and 0 deletions
|
@ -1301,6 +1301,10 @@ def sls(mods, test=None, exclude=None, queue=False, sync_mods=None, **kwargs):
|
|||
high_ = serial.load(fp_)
|
||||
return st_.state.call_high(high_, orchestration_jid)
|
||||
|
||||
# If the state file is an integer, convert to a string then to unicode
|
||||
if isinstance(mods, six.integer_types):
|
||||
mods = salt.utils.stringutils.to_unicode(str(mods)) # future lint: disable=blacklisted-function
|
||||
|
||||
if isinstance(mods, six.string_types):
|
||||
mods = mods.split(',')
|
||||
|
||||
|
|
2
tests/integration/files/file/base/12345.sls
Normal file
2
tests/integration/files/file/base/12345.sls
Normal file
|
@ -0,0 +1,2 @@
|
|||
always-passes:
|
||||
test.succeed_without_changes
|
|
@ -1957,3 +1957,19 @@ class StateModuleTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
state_file = os.path.join(TMP, 'testfile')
|
||||
if os.path.isfile(state_file):
|
||||
os.remove(state_file)
|
||||
|
||||
def test_state_sls_integer_name(self):
|
||||
'''
|
||||
This tests the case where the state file is named
|
||||
only with integers
|
||||
'''
|
||||
state_run = self.run_function(
|
||||
'state.sls',
|
||||
mods='12345'
|
||||
)
|
||||
|
||||
state_id = 'test_|-always-passes_|-always-passes_|-succeed_without_changes'
|
||||
self.assertIn(state_id, state_run)
|
||||
self.assertEqual(state_run[state_id]['comment'],
|
||||
'Success!')
|
||||
self.assertTrue(state_run[state_id]['result'])
|
||||
|
|
Loading…
Add table
Reference in a new issue