-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47372 from gtmanfred/grains
Allow for passing in previously compiled grains to custom grain modules
- Loading branch information
Showing
5 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/integration/files/file/base/_grains/test_custom_grains.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def test(grains): | ||
if 'os' in grains: | ||
return {'custom_grain_test': 'itworked'} | ||
return {'custom_grain_test': 'itdidntwork'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
''' | ||
Test the core grains | ||
''' | ||
|
||
# Import python libs | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
# Import Salt Testing libs | ||
from tests.support.case import ModuleCase | ||
|
||
|
||
class TestGrainsCore(ModuleCase): | ||
''' | ||
Test the core grains grains | ||
''' | ||
|
||
def test_grains_passed_to_custom_grain(self): | ||
''' | ||
test if current grains are passed to grains module functions that have a grains argument | ||
''' | ||
self.assertEqual(self.run_function('grains.get', ['custom_grain_test']), 'itworked') |