예제 #1
0
def test_cleanup_volumes(mock_client):
    mock_client.volumes.return_value = volumes = {
        'Volumes': [
            {
                'Mountpoint': 'unused',
                'Labels': None,
                'Driver': 'unused',
                'Name': u'one'
            },
            {
                'Mountpoint': 'unused',
                'Labels': None,
                'Driver': 'unused',
                'Name': u'two'
            },
        ],
        'Warnings':
        None,
    }

    docker_gc.cleanup_volumes(mock_client, False)
    assert mock_client.remove_volume.mock_calls == [
        mock.call(name=volume['Name'])
        for volume in reversed(volumes['Volumes'])
    ]
예제 #2
0
def test_filter_cleanup_volumes(mock_client):
    mock_client.volumes.return_value = {
        'Volumes': [
            {
                'Mountpoint': 'unused',
                'Labels': None,
                'Driver': 'unused',
                'Name': u'unused'
            },
            {
                'Mountpoint': 'filtered',
                'Labels': None,
                'Driver': 'unused',
                'Name': u'filtered'
            },
        ],
        'Warnings':
        None,
    }

    docker_gc.cleanup_volumes(mock_client, False, set(['filtered']))
    assert mock_client.remove_volume.mock_calls == [mock.call(name='unused')]
예제 #3
0
def test_cleanup_volumes(mock_client):
    mock_client.volumes.return_value = volumes = {
        'Volumes': [
            {
                'Mountpoint': 'unused',
                'Labels': None,
                'Driver': 'unused',
                'Name': u'one'
            },
            {
                'Mountpoint': 'unused',
                'Labels': None,
                'Driver': 'unused',
                'Name': u'two'
            },
        ],
        'Warnings': None,
    }

    docker_gc.cleanup_volumes(mock_client, False)
    assert mock_client.remove_volume.mock_calls == [
        mock.call(name=volume['Name'])
        for volume in reversed(volumes['Volumes'])
    ]