From 869d13048d927e59a195082c712f65ef2c07197a Mon Sep 17 00:00:00 2001 From: Athmane Madjoudj Date: Apr 08 2014 17:20:43 +0000 Subject: Add more tests --- diff --git a/docker-run_tests.sh b/docker-run_tests.sh index 79cf657..b6bf6da 100755 --- a/docker-run_tests.sh +++ b/docker-run_tests.sh @@ -1,10 +1,30 @@ -#!/bin/bash +#!/bin/bash # A script to test the official CentOS docker-images. # Author: Athmane Madjoudj EPEL6_RELEASE_URL="http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm" EPEL6_GPGKEY_URL="https://fedoraproject.org/static/0608B895.txt" +# A function to test an output of a command +# arg1: Command to run +# arg2: Expected output +# +expect_output(){ + if [ -z "$2" ] + then + printf "We need two args\n" + return 98 + fi + $1 | grep "$2" + if [ $? -eq 0 ] + then + printf "Test PASSED\n" + else + printf "Test \'$1\' FAILED: expecting %s\n" $2 + fi + +} + enable_epel() { printf "Installing EPEL and some tools ...\n" yum -y install wget openssh-clients @@ -26,13 +46,20 @@ test_get_centos_img() { docker pull centos } +test_centos_img_installed(){ + printf "TEST 2: Checking if CentOS image was installed correctly ...\n" + expect_output 'docker images' 'centos' + +} + test_centos_img_runcmd() { - printf "TEST 2: Running a command inside CentOS image ...\n" - docker run centos cat /etc/centos-release | grep 'CentOS' + printf "TEST 3: Running a command inside CentOS image ...\n" + expect_output 'docker run centos cat /etc/centos-release' 'CentOS' } run_tests() { test_get_centos_img + test_centos_img_installed test_centos_img_runcmd }