예제 #1
0
def test_working_directory_cleanup_on_exception(docker_client):
    with pytest.raises(Exception):
        with working_directory() as workdir:
            volume = docker_client.volumes.get(workdir.volume)
            assert volume.name == workdir.volume

            raise Exception("An error occurred while using a workdir")

    with pytest.raises(docker.errors.NotFound):
        docker_client.volumes.get(workdir.volume)
예제 #2
0
def test_working_directory(docker_client):
    with working_directory() as workdir:
        assert workdir.volume.startswith('epicbox-')
        node_volume = workdir.volume
        if is_docker_swarm(docker_client):
            node_name = get_swarm_nodes(docker_client)[0]
            node_volume = node_name + '/' + workdir.volume
        volume = docker_client.inspect_volume(node_volume)
        assert volume['Name'] == workdir.volume

    with pytest.raises(docker.errors.NotFound):
        docker_client.inspect_volume(node_volume)
예제 #3
0
def test_run_reuse_workdir(profile, docker_client):
    with working_directory() as workdir:
        assert workdir.node is None

        run(profile.name, 'true',
            files=[{'name': 'file', 'content': b'first run data\n'}],
            workdir=workdir)

        if is_docker_swarm(docker_client):
            assert workdir.node

        result = run(profile.name, 'cat file', workdir=workdir)

        assert result['exit_code'] == 0
        assert result['stdout'] == b'first run data\n'