Back-port #34324 to 2015.8 (#34344)

* Add test to match against custom grains

* Lint

* Forgot to add custom grain
This commit is contained in:
Nicole Thomas 2016-06-28 16:35:32 -04:00 committed by GitHub
parent 11dc0203b0
commit 94e094652c
2 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,5 @@
#!/usr/bin/env python
def myfunction():
grains = {}
grains['match'] = 'maker'
return grains

View File

@ -150,6 +150,8 @@ class MatchTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
'''
test salt grain matcher
'''
# Sync grains
self.run_salt('-t1 "*" saltutil.sync_grains')
# First-level grain (string value)
data = self.run_salt('-t 1 -G "test_grain:cheese" test.ping')
data = '\n'.join(data)
@ -159,6 +161,11 @@ class MatchTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
data = '\n'.join(data)
self.assertIn('sub_minion', data)
self.assertNotIn('minion', data.replace('sub_minion', 'stub'))
# Custom grain
data = self.run_salt('-t 1 -G "match:maker" test.ping')
data = '\n'.join(data)
self.assertIn('minion', data)
self.assertIn('sub_minion', data)
# First-level grain (list member)
data = self.run_salt('-t 1 -G "planets:earth" test.ping')
data = '\n'.join(data)