mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix playbook cli unit test (#33767)
* TestPlaybookCLI: '--flush-cache' were ignored Check that using '--flush-cache' does something * check that '_flush_cache' does something There isn't any fact by default: the assertion was true even if 'cli._flush_cache()' isn't called.
This commit is contained in:
parent
3a9083cf48
commit
7c187cae93
1 changed files with 6 additions and 1 deletions
|
@ -30,11 +30,16 @@ from ansible.cli.playbook import PlaybookCLI
|
|||
|
||||
class TestPlaybookCLI(unittest.TestCase):
|
||||
def test_flush_cache(self):
|
||||
cli = PlaybookCLI(args=["--flush-cache", "foobar.yml"])
|
||||
cli = PlaybookCLI(args=["ansible-playbook", "--flush-cache", "foobar.yml"])
|
||||
cli.parse()
|
||||
self.assertTrue(cli.options.flush_cache)
|
||||
|
||||
variable_manager = VariableManager()
|
||||
fake_loader = DictDataLoader({'foobar.yml': ""})
|
||||
inventory = InventoryManager(loader=fake_loader, sources='testhost,')
|
||||
|
||||
variable_manager.set_host_facts(inventory.get_host('testhost'), {'canary': True})
|
||||
self.assertTrue('testhost' in variable_manager._fact_cache)
|
||||
|
||||
cli._flush_cache(inventory, variable_manager)
|
||||
self.assertFalse('testhost' in variable_manager._fact_cache)
|
||||
|
|
Loading…
Reference in a new issue