|
13 | 13 | from compose.config.types import ServiceSecret |
14 | 14 | from compose.config.types import VolumeFromSpec |
15 | 15 | from compose.config.types import VolumeSpec |
| 16 | +from compose.const import API_VERSIONS |
16 | 17 | from compose.const import LABEL_CONFIG_HASH |
17 | 18 | from compose.const import LABEL_ONE_OFF |
18 | 19 | from compose.const import LABEL_PROJECT |
@@ -601,6 +602,25 @@ def test_config_dict_with_network_mode_from_container(self): |
601 | 602 | } |
602 | 603 | assert config_dict == expected |
603 | 604 |
|
| 605 | + def test_config_hash_matches_label(self): |
| 606 | + self.mock_client.inspect_image.return_value = {'Id': 'abcd'} |
| 607 | + service = Service( |
| 608 | + 'foo', |
| 609 | + image='example.com/foo', |
| 610 | + client=self.mock_client, |
| 611 | + network_mode=NetworkMode('bridge'), |
| 612 | + networks={'bridge': {}}, |
| 613 | + links=[(Service('one', client=self.mock_client), 'one')], |
| 614 | + volumes_from=[VolumeFromSpec(Service('two', client=self.mock_client), 'rw', 'service')] |
| 615 | + ) |
| 616 | + config_hash = service.config_hash |
| 617 | + |
| 618 | + for api_version in set(API_VERSIONS.values()): |
| 619 | + self.mock_client.api_version = api_version |
| 620 | + assert service._get_container_create_options({}, 1)['labels'][LABEL_CONFIG_HASH] == ( |
| 621 | + config_hash |
| 622 | + ) |
| 623 | + |
604 | 624 | def test_remove_image_none(self): |
605 | 625 | web = Service('web', image='example', client=self.mock_client) |
606 | 626 | assert not web.remove_image(ImageType.none) |
|
0 commit comments