diff --git a/tests/integration/files/file/base/issue-51499.sls b/tests/integration/files/file/base/issue-51499.sls new file mode 100644 index 000000000000..0e15e7396eae --- /dev/null +++ b/tests/integration/files/file/base/issue-51499.sls @@ -0,0 +1,6 @@ +{% if 'nonexistent_module.function' in salt %} +{% do salt.log.warning("Module is available") %} +{% endif %} +always-passes: + test.succeed_without_changes: + - name: foo diff --git a/tests/integration/modules/test_state.py b/tests/integration/modules/test_state.py index d5f20652fb44..59ecc578e0f1 100644 --- a/tests/integration/modules/test_state.py +++ b/tests/integration/modules/test_state.py @@ -2118,3 +2118,16 @@ def test_state_sls_integer_name(self): self.assertEqual(state_run[state_id]['comment'], 'Success!') self.assertTrue(state_run[state_id]['result']) + + def test_state_sls_lazyloader_allows_recursion(self): + ''' + This tests that referencing dunders like __salt__ work + context: https://github.com/saltstack/salt/pull/51499 + ''' + state_run = self.run_function('state.sls', mods='issue-51499') + + state_id = 'test_|-always-passes_|-foo_|-succeed_without_changes' + self.assertIn(state_id, state_run) + self.assertEqual(state_run[state_id]['comment'], + 'Success!') + self.assertTrue(state_run[state_id]['result'])