mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Convert the remaining tests hard-coding temporary paths.
This commit is contained in:
parent
e2168602fb
commit
e04c872c66
15 changed files with 66 additions and 34 deletions
|
@ -4,7 +4,7 @@ exclude:
|
|||
include:
|
||||
- include-test
|
||||
|
||||
/tmp/exclude-test:
|
||||
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('exclude-test') }}:
|
||||
file:
|
||||
- managed
|
||||
- source: salt://testfile
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
include:
|
||||
- to-include-test
|
||||
|
||||
/tmp/include-test:
|
||||
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('include-test') }}:
|
||||
file:
|
||||
- managed
|
||||
- source: salt://testfile
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/tmp/issue-1959-virtualenv-runas:
|
||||
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-1959-virtualenv-runas') }}:
|
||||
virtualenv.manage:
|
||||
- requirements: salt://issue-1959-virtualenv-runas/requirements.txt
|
||||
- runas: issue-1959
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/tmp/issue-2028-pip-installed:
|
||||
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2028-pip-installed') }}:
|
||||
virtualenv.managed:
|
||||
- no_site_packages: True
|
||||
- distribute: True
|
||||
|
@ -6,7 +6,7 @@
|
|||
supervisord-pip:
|
||||
pip.installed:
|
||||
- name: supervisor
|
||||
- bin_env: /tmp/issue-2028-pip-installed
|
||||
- bin_env: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2028-pip-installed') }}
|
||||
- mirrors: http://testpypi.python.org/pypi
|
||||
- require:
|
||||
- virtualenv: /tmp/issue-2028-pip-installed
|
||||
- virtualenv: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2028-pip-installed') }}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/tmp/issue-2068-template-str:
|
||||
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}:
|
||||
virtualenv:
|
||||
- managed
|
||||
- no_site_packages: True
|
||||
|
@ -8,7 +8,7 @@ pep8-pip:
|
|||
pip:
|
||||
- installed
|
||||
- name: pep8
|
||||
- bin_env: /tmp/issue-2068-template-str
|
||||
- bin_env: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}
|
||||
- mirrors: http://testpypi.python.org/pypi
|
||||
- require:
|
||||
- virtualenv: /tmp/issue-2068-template-str
|
||||
- virtualenv: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/tmp/issue-2068-template-str:
|
||||
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}:
|
||||
virtualenv.managed:
|
||||
- no_site_packages: True
|
||||
- distribute: True
|
||||
|
@ -6,7 +6,7 @@
|
|||
pep8-pip:
|
||||
pip.installed:
|
||||
- name: pep8
|
||||
- bin_env: /tmp/issue-2068-template-str
|
||||
- bin_env: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}
|
||||
- mirrors: http://testpypi.python.org/pypi
|
||||
- require:
|
||||
- virtualenv: /tmp/issue-2068-template-str
|
||||
- virtualenv: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2068-template-str') }}
|
||||
|
|
|
@ -2,4 +2,4 @@ pep8-pip:
|
|||
pip.installed:
|
||||
- name: pep8
|
||||
- mirrors: http://testpypi.python.org/pypi
|
||||
- bin_env: /tmp/issue-2087-missing-pip
|
||||
- bin_env: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('issue-2087-missing-pip') }}
|
||||
|
|
|
@ -2,4 +2,4 @@ supervisord-pip:
|
|||
pip.installed:
|
||||
- name: supervisor
|
||||
- mirrors: http://testpypi.python.org/pypi
|
||||
- bin_env: /tmp/pip-installed-errors
|
||||
- bin_env: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('pip-installed-errors') }}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/tmp/pip-installed-weird-install:
|
||||
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('pip-installed-weird-install') }}:
|
||||
virtualenv.managed:
|
||||
- no_site_packages: True
|
||||
- distribute: True
|
||||
|
@ -7,7 +7,7 @@ carbon-weird-setup:
|
|||
pip.installed:
|
||||
- name: carbon
|
||||
- no_deps: True
|
||||
- bin_env: /tmp/pip-installed-weird-install
|
||||
- bin_env: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('pip-installed-weird-install') }}
|
||||
- mirrors: http://testpypi.python.org/pypi
|
||||
- require:
|
||||
- virtualenv: /tmp/pip-installed-weird-install
|
||||
- virtualenv: {{ salt['runtests_helpers.get_sys_temp_dir_for_path']('pip-installed-weird-install') }}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
issue-2227:
|
||||
file.append:
|
||||
- name: /tmp/salttest/test.append
|
||||
- name: {{ salt['runtests_helpers.get_salt_temp_dir_for_path']('test.append') }}
|
||||
- text: HISTTIMEFORMAT='%F %T '
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/tmp/to-include-test:
|
||||
{{ salt['runtests_helpers.get_sys_temp_dir_for_path']('to-include-test') }}:
|
||||
file:
|
||||
- managed
|
||||
- source: salt://testfile
|
||||
|
|
|
@ -249,35 +249,49 @@ fi
|
|||
os.unlink(testfile)
|
||||
|
||||
def test_include(self):
|
||||
fnames = ('/tmp/include-test', '/tmp/to-include-test')
|
||||
fnames = (
|
||||
os.path.join(integration.SYS_TMP_DIR, 'include-test'),
|
||||
os.path.join(integration.SYS_TMP_DIR, 'to-include-test')
|
||||
)
|
||||
exclude_test_file = os.path.join(
|
||||
integration.SYS_TMP_DIR, 'exclude-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'))
|
||||
self.assertFalse(os.path.isfile(exclude_test_file))
|
||||
finally:
|
||||
for fname in list(fnames) + ['/tmp/exclude-test']:
|
||||
for fname in list(fnames) + [exclude_test_file]:
|
||||
if os.path.isfile(fname):
|
||||
os.remove(fname)
|
||||
|
||||
def test_exclude(self):
|
||||
fnames = ('/tmp/include-test', '/tmp/exclude-test')
|
||||
fnames = (
|
||||
os.path.join(integration.SYS_TMP_DIR, 'include-test'),
|
||||
os.path.join(integration.SYS_TMP_DIR, 'exclude-test')
|
||||
)
|
||||
to_include_test_file = os.path.join(
|
||||
integration.SYS_TMP_DIR, 'to-include-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'))
|
||||
self.assertFalse(os.path.isfile(to_include_test_file))
|
||||
finally:
|
||||
for fname in list(fnames) + ['/tmp/to-include-test']:
|
||||
for fname in list(fnames) + [to_include_test_file]:
|
||||
if os.path.isfile(fname):
|
||||
os.remove(fname)
|
||||
|
||||
def test_issue_2068_template_str(self):
|
||||
venv_dir = '/tmp/issue-2068-template-str'
|
||||
venv_dir = os.path.join(
|
||||
integration.SYS_TMP_DIR, 'issue-2068-template-str'
|
||||
)
|
||||
|
||||
try:
|
||||
ret = self.run_function(
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
'''
|
||||
Tests for the file state
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# Import salt libs
|
||||
import integration
|
||||
|
||||
|
||||
|
@ -409,7 +413,9 @@ class FileTest(integration.ModuleCase):
|
|||
'''
|
||||
# let's make use of existing state to create a file with contents to
|
||||
# test against
|
||||
tmp_file_append = '/tmp/salttest/test.append'
|
||||
tmp_file_append = os.path.join(
|
||||
integration.TMP, 'test.append'
|
||||
)
|
||||
if os.path.isfile(tmp_file_append):
|
||||
os.remove(tmp_file_append)
|
||||
self.run_function('state.sls', mods='testappend')
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
:license: Apache 2.0, see LICENSE for more details
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
@ -20,7 +21,9 @@ class PipStateTest(integration.ModuleCase):
|
|||
self.skipTest('virtualenv not installed')
|
||||
|
||||
def test_pip_installed_errors(self):
|
||||
venv_dir = '/tmp/pip-installed-errors'
|
||||
venv_dir = os.path.join(
|
||||
integration.SYS_TMP_DIR, 'pip-installed-errors'
|
||||
)
|
||||
try:
|
||||
# Since we don't have the virtualenv created, pip.installed will
|
||||
# thrown and error.
|
||||
|
@ -38,7 +41,7 @@ class PipStateTest(integration.ModuleCase):
|
|||
|
||||
# We now create the missing virtualenv
|
||||
ret = self.run_function('virtualenv.create', [venv_dir])
|
||||
self.assertTrue(ret['retcode']==0)
|
||||
self.assertEqual(ret['retcode'], 0)
|
||||
|
||||
# The state should not have any issues running now
|
||||
ret = self.run_function('state.sls', mods='pip-installed-errors')
|
||||
|
@ -70,7 +73,9 @@ class PipStateTest(integration.ModuleCase):
|
|||
if os.path.isdir(ographite):
|
||||
shutil.rmtree(ographite)
|
||||
|
||||
venv_dir = '/tmp/pip-installed-weird-install'
|
||||
venv_dir = os.path.join(
|
||||
integration.SYS_TMP_DIR, 'pip-installed-weird-install'
|
||||
)
|
||||
try:
|
||||
# Since we don't have the virtualenv created, pip.installed will
|
||||
# thrown and error.
|
||||
|
@ -98,7 +103,9 @@ class PipStateTest(integration.ModuleCase):
|
|||
def test_issue_2028_pip_installed_state(self):
|
||||
ret = self.run_function('state.sls', mods='issue-2028-pip-installed')
|
||||
|
||||
venv_dir = '/tmp/issue-2028-pip-installed'
|
||||
venv_dir = os.path.join(
|
||||
integration.SYS_TMP_DIR, 'issue-2028-pip-installed'
|
||||
)
|
||||
|
||||
try:
|
||||
self.assertTrue(isinstance(ret, dict)), ret
|
||||
|
@ -115,7 +122,10 @@ class PipStateTest(integration.ModuleCase):
|
|||
shutil.rmtree(venv_dir)
|
||||
|
||||
def test_issue_2087_missing_pip(self):
|
||||
venv_dir = '/tmp/issue-2087-missing-pip'
|
||||
venv_dir = os.path.join(
|
||||
integration.SYS_TMP_DIR, 'issue-2087-missing-pip'
|
||||
)
|
||||
|
||||
try:
|
||||
# XXX: Once state.template_str is fixed, consider not using a file
|
||||
# for this test.
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
# Import python libs
|
||||
import os
|
||||
import shutil
|
||||
import integration
|
||||
|
||||
# Import salt libs
|
||||
import integration
|
||||
from saltunittest import skipIf, destructiveTest
|
||||
|
||||
|
||||
|
@ -24,7 +24,9 @@ class VirtualenvTest(integration.ModuleCase):
|
|||
|
||||
uinfo = self.run_function('user.info', [user])
|
||||
|
||||
venv_dir = '/tmp/issue-1959-virtualenv-runas'
|
||||
venv_dir = os.path.join(
|
||||
integration.SYS_TMP_DIR, 'issue-1959-virtualenv-runas'
|
||||
)
|
||||
try:
|
||||
ret = self.run_function(
|
||||
'state.sls', mods='issue-1959-virtualenv-runas'
|
||||
|
|
Loading…
Add table
Reference in a new issue