mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add initial matcher tests
This commit is contained in:
parent
5c09aa3778
commit
19baf0f577
1 changed files with 60 additions and 0 deletions
60
tests/integration/shell/matcher.py
Normal file
60
tests/integration/shell/matcher.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
# Import python libs
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class MatchTest(integration.ShellCase):
|
||||
'''
|
||||
Test salt matchers
|
||||
'''
|
||||
def test_list(self):
|
||||
'''
|
||||
test salt -L matcher
|
||||
'''
|
||||
data = self.run_salt('-L minion test.ping')
|
||||
data = '\n'.join(data)
|
||||
self.assertIn('minion', data)
|
||||
self.assertNotIn('sub_minion', data)
|
||||
data = self.run_salt('-L minion,sub_minion test.ping')
|
||||
data = '\n'.join(data)
|
||||
self.assertIn('minion', data)
|
||||
self.assertIn('sub_minion', data)
|
||||
|
||||
def test_glob(self):
|
||||
'''
|
||||
test salt glob matcher
|
||||
'''
|
||||
data = self.run_salt('minion test.ping')
|
||||
data = '\n'.join(data)
|
||||
self.assertIn('minion', data)
|
||||
self.assertNotIn('sub_minion', data)
|
||||
data = self.run_salt('"*" test.ping')
|
||||
data = '\n'.join(data)
|
||||
self.assertIn('minion', data)
|
||||
self.assertIn('sub_minion', data)
|
||||
|
||||
def test_regex(self):
|
||||
'''
|
||||
test salt regex matcher
|
||||
'''
|
||||
data = self.run_salt('-E "^minion$" test.ping')
|
||||
data = '\n'.join(data)
|
||||
self.assertIn('minion', data)
|
||||
self.assertNotIn('sub_minion', data)
|
||||
data = self.run_salt('-E ".*" test.ping')
|
||||
data = '\n'.join(data)
|
||||
self.assertIn('minion', data)
|
||||
self.assertIn('sub_minion', data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(KeyTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
Loading…
Add table
Reference in a new issue