mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Add regression test for creating images with image name insead of ID
Also changed an existing test to use the new with_tempdir decorator
This commit is contained in:
parent
4ed47e839c
commit
798134caa3
@ -16,7 +16,7 @@ from tests.support.unit import skipIf
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.docker import with_network, random_name
|
||||
from tests.support.paths import FILES, TMP
|
||||
from tests.support.helpers import destructiveTest
|
||||
from tests.support.helpers import destructiveTest, with_tempdir
|
||||
from tests.support.mixins import SaltReturnAssertsMixin
|
||||
|
||||
# Import Salt Libs
|
||||
@ -33,24 +33,6 @@ log = logging.getLogger(__name__)
|
||||
IPV6_ENABLED = bool(salt.utils.network.ip_addrs6(include_loopback=True))
|
||||
|
||||
|
||||
def with_temp_dir(func):
|
||||
'''
|
||||
Generate a temp directory for a test
|
||||
'''
|
||||
@functools.wraps(func)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
tempdir = tempfile.mkdtemp(dir=TMP)
|
||||
try:
|
||||
return func(self, tempdir, *args, **kwargs)
|
||||
finally:
|
||||
try:
|
||||
salt.utils.files.rm_rf(tempdir)
|
||||
except OSError as exc:
|
||||
if exc.errno != errno.ENOENT:
|
||||
raise
|
||||
return wrapper
|
||||
|
||||
|
||||
def container_name(func):
|
||||
'''
|
||||
Generate a randomized name for a container and clean it up afterward
|
||||
@ -126,7 +108,7 @@ class DockerContainerTestCase(ModuleCase, SaltReturnAssertsMixin):
|
||||
log.debug('ret = %s', ret)
|
||||
return ret
|
||||
|
||||
@with_temp_dir
|
||||
@with_tempdir()
|
||||
@container_name
|
||||
def test_running_with_no_predefined_volume(self, name, bind_dir_host):
|
||||
'''
|
||||
@ -572,6 +554,21 @@ class DockerContainerTestCase(ModuleCase, SaltReturnAssertsMixin):
|
||||
'Forcibly removed container \'{0}\''.format(name)
|
||||
)
|
||||
|
||||
@container_name
|
||||
def test_running_image_name(self, name):
|
||||
'''
|
||||
Ensure that we create the container using the image name instead of ID
|
||||
'''
|
||||
ret = self.run_state(
|
||||
'docker_container.running',
|
||||
name=name,
|
||||
image=self.image,
|
||||
shutdown_timeout=1,
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
ret = self.run_function('docker.inspect_container', [name])
|
||||
self.assertEqual(ret['Config']['Image'], self.image)
|
||||
|
||||
@container_name
|
||||
def test_env_with_running_container(self, name):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user