1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
import unittest
from ansiblelint import RulesCollection
from ansiblelint.rules.VariableHasSpacesRule import VariableHasSpacesRule
from test import RunFromText
TASK_VARIABLES = '''
- name: good variable format
debug:
msg: "{{ good_format }}"
- name: good variable format
debug:
msg: "Value: {{ good_format }}"
- name: jijna escaping allowed
debug:
msg: "{{ '{{' }}"
- name: jijna escaping allowed
shell: docker info --format '{{ '{{' }}json .Swarm.LocalNodeState{{ '}}' }}' | tr -d '"'
- name: bad variable format
debug:
msg: "{{bad_format}}"
- name: bad variable format
debug:
msg: "Value: {{ bad_format}}"
- name: bad variable format
debug:
msg: "{{bad_format }}"
'''
class TestVariableHasSpaces(unittest.TestCase):
collection = RulesCollection()
collection.register(VariableHasSpacesRule())
def setUp(self):
self.runner = RunFromText(self.collection)
def test_variable_has_spaces(self):
results = self.runner.run_role_tasks_main(TASK_VARIABLES)
self.assertEqual(3, len(results))
|