Add unit test for comparing containers with the same env vars

This commit is contained in:
Erik Johnson 2018-11-06 13:30:12 -06:00 committed by rallytime
parent cf7cb4beeb
commit fc26ae8ea3
No known key found for this signature in database
GPG key ID: E8F1A4B90D0DEA19

View file

@ -840,6 +840,35 @@ class DockerTestCase(TestCase, LoaderModuleMockMixin):
ret = docker_mod.compare_container('container1', 'container2')
self.assertEqual(ret, {})
def test_compare_container_env_order(self):
'''
Test comparing two containers when the order of the Env HostConfig
values are different, but the values are the same.
'''
def _inspect_container_effect(id_):
return {
'container1': {'Config': {},
'HostConfig': {
'Env': [
'FOO=bar',
'HELLO=world',
]
}},
'container2': {'Config': {},
'HostConfig': {
'Env': [
'HELLO=world',
'FOO=bar',
]
}},
}[id_]
inspect_container_mock = MagicMock(side_effect=_inspect_container_effect)
with patch.object(docker_mod, 'inspect_container', inspect_container_mock):
ret = docker_mod.compare_container('container1', 'container2')
self.assertEqual(ret, {})
def test_resolve_tag(self):
'''
Test the resolve_tag function. It runs docker.insect_image on the image