mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add include and exclude test cases. Refs #2068.
This commit is contained in:
parent
c80ea695b1
commit
cc10ed1906
4 changed files with 50 additions and 0 deletions
10
tests/integration/files/file/base/exclude-test.sls
Normal file
10
tests/integration/files/file/base/exclude-test.sls
Normal file
|
@ -0,0 +1,10 @@
|
|||
exclude:
|
||||
- to-include-test
|
||||
|
||||
include:
|
||||
- include-test
|
||||
|
||||
/tmp/exclude-test:
|
||||
file:
|
||||
- managed
|
||||
- source: salt://testfile
|
7
tests/integration/files/file/base/include-test.sls
Normal file
7
tests/integration/files/file/base/include-test.sls
Normal file
|
@ -0,0 +1,7 @@
|
|||
include:
|
||||
- to-include-test
|
||||
|
||||
/tmp/include-test:
|
||||
file:
|
||||
- managed
|
||||
- source: salt://testfile
|
4
tests/integration/files/file/base/to-include-test.sls
Normal file
4
tests/integration/files/file/base/to-include-test.sls
Normal file
|
@ -0,0 +1,4 @@
|
|||
/tmp/to-include-test:
|
||||
file:
|
||||
- managed
|
||||
- source: salt://testfile
|
|
@ -141,6 +141,35 @@ fi
|
|||
finally:
|
||||
os.unlink('/tmp/salttest/issue-1879')
|
||||
|
||||
def test_include(self):
|
||||
fnames = ('/tmp/include-test', '/tmp/to-include-test')
|
||||
try:
|
||||
ret = self.run_function('state.sls', mods='include-test')
|
||||
for part in ret.itervalues():
|
||||
self.assertTrue(part['result'])
|
||||
for fname in fnames:
|
||||
self.assertTrue(os.path.isfile(fname))
|
||||
self.assertFalse(os.path.isfile('/tmp/exclude-test'))
|
||||
finally:
|
||||
for fname in list(fnames) + ['/tmp/exclude-test']:
|
||||
if os.path.isfile(fname):
|
||||
os.remove(fname)
|
||||
|
||||
def test_exclude(self):
|
||||
fnames = ('/tmp/include-test', '/tmp/exclude-test')
|
||||
try:
|
||||
ret = self.run_function('state.sls', mods='exclude-test')
|
||||
for part in ret.itervalues():
|
||||
self.assertTrue(part['result'])
|
||||
for fname in fnames:
|
||||
self.assertTrue(os.path.isfile(fname))
|
||||
self.assertFalse(os.path.isfile('/tmp/to-include-test'))
|
||||
finally:
|
||||
for fname in list(fnames) + ['/tmp/to-include-test']:
|
||||
if os.path.isfile(fname):
|
||||
os.remove(fname)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue