(self)
| 1534 | |
| 1535 | class LinkTest(BaseAPIIntegrationTest): |
| 1536 | def test_remove_link(self): |
| 1537 | # Create containers |
| 1538 | container1 = self.client.create_container( |
| 1539 | TEST_IMG, 'cat', detach=True, stdin_open=True |
| 1540 | ) |
| 1541 | container1_id = container1['Id'] |
| 1542 | self.tmp_containers.append(container1_id) |
| 1543 | self.client.start(container1_id) |
| 1544 | |
| 1545 | # Create Link |
| 1546 | # we don't want the first / |
| 1547 | link_path = self.client.inspect_container(container1_id)['Name'][1:] |
| 1548 | link_alias = 'mylink' |
| 1549 | |
| 1550 | container2 = self.client.create_container( |
| 1551 | TEST_IMG, 'cat', host_config=self.client.create_host_config( |
| 1552 | links={link_path: link_alias} |
| 1553 | ) |
| 1554 | ) |
| 1555 | container2_id = container2['Id'] |
| 1556 | self.tmp_containers.append(container2_id) |
| 1557 | self.client.start(container2_id) |
| 1558 | |
| 1559 | # Remove link |
| 1560 | linked_name = self.client.inspect_container(container2_id)['Name'][1:] |
| 1561 | link_name = f'{linked_name}/{link_alias}' |
| 1562 | self.client.remove_container(link_name, link=True) |
| 1563 | |
| 1564 | # Link is gone |
| 1565 | containers = self.client.containers(all=True) |
| 1566 | retrieved = [x for x in containers if link_name in x['Names']] |
| 1567 | assert len(retrieved) == 0 |
| 1568 | |
| 1569 | # Containers are still there |
| 1570 | retrieved = [ |
| 1571 | x for x in containers if x['Id'].startswith(container1_id) or |
| 1572 | x['Id'].startswith(container2_id) |
| 1573 | ] |
| 1574 | assert len(retrieved) == 2 |
nothing calls this directly
no test coverage detected