Skip to content

Commit

Permalink
Back-port #34324 to 2015.8 (#34344)
Browse files Browse the repository at this point in the history
* Add test to match against custom grains

* Lint

* Forgot to add custom grain
  • Loading branch information
Nicole Thomas committed Jun 28, 2016
1 parent 11dc020 commit 94e0946
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/integration/files/file/base/_grains/matcher_grain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python
def myfunction():
grains = {}
grains['match'] = 'maker'
return grains
7 changes: 7 additions & 0 deletions tests/integration/shell/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ def test_grain(self):
'''
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)
Expand All @@ -159,6 +161,11 @@ def test_grain(self):
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)
Expand Down

0 comments on commit 94e0946

Please sign in to comment.