From d356ed0d53c37cd4cfbb90385a65c238335743fa Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sun, 13 Dec 2015 14:05:29 +0100 Subject: [PATCH] sharness: add t0300-docker-image.sh License: MIT Signed-off-by: Christian Couder --- test/sharness/t0300-docker-image.sh | 60 +++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 test/sharness/t0300-docker-image.sh diff --git a/test/sharness/t0300-docker-image.sh b/test/sharness/t0300-docker-image.sh new file mode 100755 index 00000000000..446da7a8e2a --- /dev/null +++ b/test/sharness/t0300-docker-image.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# +# Copyright (c) 2015 Christian Couder +# MIT Licensed; see the LICENSE file in this repository. +# + +test_description="Test docker image" + +. lib/test-lib.sh + +test_expect_success "docker is installed" ' + type docker +' + +test_expect_success "'docker --version' works" ' + docker --version >actual +' + +test_expect_success "'docker --version' output looks good" ' + egrep "^Docker version" actual +' + +test_expect_success "current user is in the 'docker' group" ' + groups | egrep "\bdocker\b" +' + +TEST_TRASH_DIR=$(pwd) +TEST_SCRIPTS_DIR=$(dirname "$TEST_TRASH_DIR") +TEST_TESTS_DIR=$(dirname "$TEST_SCRIPTS_DIR") +APP_ROOT_DIR=$(dirname "$TEST_TESTS_DIR") + +test_expect_success "docker image build succeeds" ' + docker_build "$APP_ROOT_DIR" >actual +' + +test_expect_success "docker image build output looks good" ' + SUCCESS_LINE=$(egrep "^Successfully built" actual) && + IMAGE_ID=$(expr "$SUCCESS_LINE" : "^Successfully built \(.*\)") || + test_fsh cat actual +' + +test_expect_success "docker image runs" ' + DOC_ID=$(docker_run "$IMAGE_ID") +' + +test_expect_success "simple command can be run in docker container" ' + docker_exec "$DOC_ID" "echo Hello Worlds" >actual +' + +test_expect_success "simple command output looks good" ' + echo "Hello Worlds" >expected && + test_cmp expected actual +' + +test_expect_success "stop docker container" ' + docker_stop "$DOC_ID" +' + +test_done +