mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Also add tests around that code path
This commit is contained in:
parent
c403f01971
commit
0ff04ad41b
2 changed files with 21 additions and 1 deletions
|
@ -422,7 +422,7 @@ class DataLoader:
|
||||||
if allow_dir:
|
if allow_dir:
|
||||||
found.extend(self._get_dir_vars_files(to_text(full_path), extensions))
|
found.extend(self._get_dir_vars_files(to_text(full_path), extensions))
|
||||||
else:
|
else:
|
||||||
next
|
continue
|
||||||
else:
|
else:
|
||||||
found.append(full_path)
|
found.append(full_path)
|
||||||
break
|
break
|
||||||
|
|
|
@ -147,6 +147,26 @@ class TestRole(unittest.TestCase):
|
||||||
self.assertEqual(len(r._task_blocks), 1)
|
self.assertEqual(len(r._task_blocks), 1)
|
||||||
assert isinstance(r._task_blocks[0], Block)
|
assert isinstance(r._task_blocks[0], Block)
|
||||||
|
|
||||||
|
@patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop)
|
||||||
|
def test_load_role_with_tasks_dir_vs_file(self):
|
||||||
|
|
||||||
|
fake_loader = DictDataLoader({
|
||||||
|
"/etc/ansible/roles/foo_tasks/tasks/custom_main/foo.yml": """
|
||||||
|
- command: bar
|
||||||
|
""",
|
||||||
|
"/etc/ansible/roles/foo_tasks/tasks/custom_main.yml": """
|
||||||
|
- command: baz
|
||||||
|
""",
|
||||||
|
})
|
||||||
|
|
||||||
|
mock_play = MagicMock()
|
||||||
|
mock_play.ROLE_CACHE = {}
|
||||||
|
|
||||||
|
i = RoleInclude.load('foo_tasks', play=mock_play, loader=fake_loader)
|
||||||
|
r = Role.load(i, play=mock_play, from_files=dict(tasks='custom_main'))
|
||||||
|
|
||||||
|
self.assertEqual(r._task_blocks[0]._ds[0]['command'], 'baz')
|
||||||
|
|
||||||
@patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop)
|
@patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop)
|
||||||
def test_load_role_with_handlers(self):
|
def test_load_role_with_handlers(self):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue