Merge pull request #48752 from garethgreenaway/fix_state_file_all_integers

[2018.3] Fix when state file is integers
This commit is contained in:
Nicole Thomas 2018-07-25 11:03:01 -04:00 committed by GitHub
commit f2ef2d3ef6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -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(',')

View File

@ -0,0 +1,2 @@
always-passes:
test.succeed_without_changes

View File

@ -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'])