Skip to content

Commit

Permalink
Fix playbook cli unit test (ansible#33767)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
pilou- authored and gundalow committed Dec 13, 2017
1 parent 3a9083c commit 7c187ca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/units/cli/test_playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@

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)

0 comments on commit 7c187ca

Please sign in to comment.