#!/bin/bash

export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export DEST=.

TESTFLAGS="$TESTFLAGS -test.timeout=30m -check.v"

run_integration_test() {
    echo "Running integration test against ${DOCKER_DAEMON_VERSION}"
    
    bundle .integration-daemon-start

    cd integration
    TESTVERBOSE=$TESTVERBOSE go test $TESTFLAGS
    cd ..

    bundle .integration-daemon-stop
    
    echo
}

if test -n "${DAEMON_VERSION}" && test "${DAEMON_VERSION}" != "all"; then
    if test "${DAEMON_VERSION}" = "default"; then
        DAEMON_VERSION="${DEFAULT_DOCKER_VERSION}"
    fi
    for version in $(echo ${DAEMON_VERSION} | cut -f1); do
        DOCKER_DAEMON_VERSION="${version}" run_integration_test
    done
else
    for version in $(echo ${DOCKER_VERSIONS} | cut -f1); do
        DOCKER_DAEMON_VERSION="${version}" run_integration_test
    done
fi


