mirror of
https://github.com/docker/compose.git
synced 2025-07-21 04:34:38 +02:00
Use 12 characters for the short id to match docker and fix backwards compatibility.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
28e652daec
commit
421981e7d2
@ -60,7 +60,7 @@ class Container(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def short_id(self):
|
def short_id(self):
|
||||||
return self.id[:10]
|
return self.id[:12]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -12,8 +12,9 @@ from compose.container import get_container_name
|
|||||||
class ContainerTest(unittest.TestCase):
|
class ContainerTest(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
self.container_id = "abcabcabcbabc12345"
|
||||||
self.container_dict = {
|
self.container_dict = {
|
||||||
"Id": "abc",
|
"Id": self.container_id,
|
||||||
"Image": "busybox:latest",
|
"Image": "busybox:latest",
|
||||||
"Command": "top",
|
"Command": "top",
|
||||||
"Created": 1387384730,
|
"Created": 1387384730,
|
||||||
@ -41,19 +42,22 @@ class ContainerTest(unittest.TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
container.dictionary,
|
container.dictionary,
|
||||||
{
|
{
|
||||||
"Id": "abc",
|
"Id": self.container_id,
|
||||||
"Image": "busybox:latest",
|
"Image": "busybox:latest",
|
||||||
"Name": "/composetest_db_1",
|
"Name": "/composetest_db_1",
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_from_ps_prefixed(self):
|
def test_from_ps_prefixed(self):
|
||||||
self.container_dict['Names'] = ['/swarm-host-1' + n for n in self.container_dict['Names']]
|
self.container_dict['Names'] = [
|
||||||
|
'/swarm-host-1' + n for n in self.container_dict['Names']
|
||||||
|
]
|
||||||
|
|
||||||
container = Container.from_ps(None,
|
container = Container.from_ps(
|
||||||
self.container_dict,
|
None,
|
||||||
has_been_inspected=True)
|
self.container_dict,
|
||||||
|
has_been_inspected=True)
|
||||||
self.assertEqual(container.dictionary, {
|
self.assertEqual(container.dictionary, {
|
||||||
"Id": "abc",
|
"Id": self.container_id,
|
||||||
"Image": "busybox:latest",
|
"Image": "busybox:latest",
|
||||||
"Name": "/composetest_db_1",
|
"Name": "/composetest_db_1",
|
||||||
})
|
})
|
||||||
@ -142,6 +146,10 @@ class ContainerTest(unittest.TestCase):
|
|||||||
self.assertEqual(container.get('HostConfig.VolumesFrom'), ["volume_id"])
|
self.assertEqual(container.get('HostConfig.VolumesFrom'), ["volume_id"])
|
||||||
self.assertEqual(container.get('Foo.Bar.DoesNotExist'), None)
|
self.assertEqual(container.get('Foo.Bar.DoesNotExist'), None)
|
||||||
|
|
||||||
|
def test_short_id(self):
|
||||||
|
container = Container(None, self.container_dict, has_been_inspected=True)
|
||||||
|
assert container.short_id == self.container_id[:12]
|
||||||
|
|
||||||
|
|
||||||
class GetContainerNameTestCase(unittest.TestCase):
|
class GetContainerNameTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user