#!/bin/bash
#
# Test the Perl image in OpenShift.
#
# IMAGE_NAME specifies a name of the candidate image used for testing.
# The image has to be available before this script is executed.
#

THISDIR=$(dirname ${BASH_SOURCE[0]})

source ${THISDIR}/test-lib.sh
source ${THISDIR}/test-lib-openshift.sh

set -exo nounset

test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
test -n "${VERSION-}" || false 'make sure $VERSION is defined'

ct_os_cluster_up

# TODO: We should ideally use a local directory instead of ${VERSION}/test/sample-test-app,
# so we can test changes in that example app that are done as part of the PR
ct_os_test_s2i_app ${IMAGE_NAME} "https://github.com/sclorg/s2i-perl-container.git" ${VERSION}/test/sample-test-app "Everything is OK"

ct_os_test_s2i_app ${IMAGE_NAME} "https://github.com/sclorg/dancer-ex.git" . 'Welcome to your Dancer application on OpenShift'

# TODO: this was not working because the referenced example dir was added as part of this commit
ct_os_test_template_app ${IMAGE_NAME} \
                        ${THISDIR}/sample-test-app.json \
                        perl \
                        "Everything is OK" \
                        8080 http 200 "-p SOURCE_REPOSITORY_REF=staging -p VERSION=${VERSION} -p NAME=perl-testing"

