diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2017-09-18 14:21:25 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2017-09-18 14:21:48 +0200 |
commit | d56e0862426b9da277ec226ba53710f650442432 (patch) | |
tree | b93a79cb35ee53d8b3813288eb3908078ae7a34f | |
parent | 3a317451f6fcb58d81a01c90bbee88e1d8e6e600 (diff) |
Remove shell code which is not used anymore
-rw-r--r-- | bin/core/imag-store/tests/001-create_test.sh | 175 | ||||
-rw-r--r-- | bin/core/imag-store/tests/002-retrieve_test.sh | 85 | ||||
-rw-r--r-- | bin/core/imag-store/tests/003-delete_test.sh | 30 | ||||
-rw-r--r-- | bin/core/imag-store/tests/Makefile | 14 | ||||
-rw-r--r-- | bin/core/imag-store/tests/utils.sh | 6 | ||||
-rw-r--r-- | tests/utils.sh | 106 |
6 files changed, 0 insertions, 416 deletions
diff --git a/bin/core/imag-store/tests/001-create_test.sh b/bin/core/imag-store/tests/001-create_test.sh deleted file mode 100644 index 591c15ba..00000000 --- a/bin/core/imag-store/tests/001-create_test.sh +++ /dev/null @@ -1,175 +0,0 @@ -#!/usr/bin/env bash - -source $(dirname ${BASH_SOURCE[0]})/../../tests/utils.sh -source $(dirname ${BASH_SOURCE[0]})/utils.sh - -test_call() { - imag-store create -p test-call - if [[ ! $? -eq 0 ]]; then - err "Return value should be zero, was non-zero" - return 1; - fi -} - -test_call_id() { - imag-store create -i test-call - if [[ ! $? -eq 0 ]]; then - err "Return value should be zero, was non-zero" - return 1; - fi -} - -test_call_no_id() { - imag-store create - if [[ ! $? -eq 1 ]]; then - err "Return value should be zero, was non-zero" - return 1; - fi -} - -test_mkstore() { - imag-store create -p test-mkstore || { err "Calling imag failed"; return 1; } - if [[ -d ${STORE} ]]; then - out "Store exists." - else - err "No store created" - return 1 - fi -} - -test_std_header() { - local expected=$(cat <<EOS ---- -[imag] -links = [] -version = "0.4.0" ---- - -EOS -) - - imag-store create -p test-std-header - local result=$(cat ${STORE}/test-std-header) - if [[ "$expected" == "$result" ]]; then - out "Expected store entry == result" - else - err "${STORE}/test-std-header differs from expected" - return 1 - fi -} - -test_std_header_plus_custom() { - local expected=$(cat <<EOS ---- -[imag] -links = [] -version = "0.4.0" - -[zzz] -zzz = "z" ---- - -EOS -) - - imag-store create -p test-std-header-plus-custom entry -h zzz.zzz=z - local result=$(cat ${STORE}/test-std-header-plus-custom) - if [[ "$expected" == "$result" ]]; then - out "Expected store entry == result" - else - err "${STORE}/test differs from expected" - return 1 - fi -} - -test_std_header_plus_custom_multiheader() { - local expected=$(cat <<EOS ---- -[foo] -bar = "baz" - -[imag] -links = [] -version = "0.4.0" - -[zzz] -zzz = "z" ---- - -EOS -) - - local filename="test-std-header-plus-custom-multiheader" - imag-store create -p $filename entry -h zzz.zzz=z foo.bar=baz - local result=$(cat ${STORE}/$filename) - if [[ "$expected" == "$result" ]]; then - out "Expected store entry == result" - else - err "${STORE}/$filename differs from expected" - return 1 - fi -} - - -test_std_header_plus_custom_multiheader_same_section() { - local expected=$(cat <<EOS ---- -[imag] -links = [] -version = "0.4.0" - -[zzz] -bar = "baz" -zzz = "z" ---- - -EOS -) - - local filename="test-std-header-plus-custom-mutliheader-same-section" - imag-store create -p $filename entry -h zzz.zzz=z zzz.bar=baz - local result=$(cat ${STORE}/$filename) - if [[ "$expected" == "$result" ]]; then - out "Expected store entry == result" - else - err "${STORE}/$filename differs from expected" - return 1 - fi -} - -test_std_header_plus_custom_and_content() { - local expected=$(cat <<EOS ---- -[imag] -links = [] -version = "0.4.0" - -[zzz] -zzz = "z" ---- -content -EOS -) - - local name="test-std-header-plus-custom-and-content" - imag-store create -p $name entry -h zzz.zzz=z -c content - local result=$(cat ${STORE}/$name) - if [[ "$expected" == "$result" ]]; then - out "Expected store entry == result" - else - err "${STORE}/test differs from expected" - return 1 - fi -} - -invoke_tests \ - test_call \ - test_call_id \ - test_call_no_id \ - test_mkstore \ - test_std_header \ - test_std_header_plus_custom \ - test_std_header_plus_custom_multiheader \ - test_std_header_plus_custom_multiheader_same_section \ - test_std_header_plus_custom_and_content - diff --git a/bin/core/imag-store/tests/002-retrieve_test.sh b/bin/core/imag-store/tests/002-retrieve_test.sh deleted file mode 100644 index e7ba5962..00000000 --- a/bin/core/imag-store/tests/002-retrieve_test.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash - -source $(dirname ${BASH_SOURCE[0]})/../../tests/utils.sh -source $(dirname ${BASH_SOURCE[0]})/utils.sh - -std_header() { - cat <<EOS ---- -[imag] -links = [] -version = "0.4.0" ---- -EOS -} - -retrieve() { - silent imag-store retrieve $* -} - -test_retrieve_nothing() { - local id="test-retrieve_nothing" - - imag-store create -p ${id} || { err "create failed"; return 1; } - - out "Going to test the retrieve functionality now" - local zero_out="$(retrieve --id ${id})" || return 1 - out "Retrieving for zero_out finished" - - if [[ ! -z "$zero_out" ]]; then - err "Expected zero output, got '$zero_out'" - return 1 - fi -} - -test_retrieve_content() { - local id="test-retrieve_simple" - - imag-store create -p ${id} || { err "create failed"; return 1; } - - out "Going to test the retrieve functionality now" - - local content_out="$(retrieve --id ${id} --content)" || return 1 - out "Retrieving for content_out finished" - - if [[ ! -z "$content_out" ]]; then - err "Expected content output == zero output, got '$content_out'" - return 1 - fi -} - -test_retrieve_header() { - local id="test-retrieve_simple" - - imag-store create -p ${id} || { err "create failed"; return 1; } - - out "Going to test the retrieve functionality now" - local header_out="$(retrieve --id ${id} --header)" - out "Retrieving for header_out finished" - - if [[ ! "$header_out" != "$(std_header)" ]]; then - err "Expected header as output, got '$header_out'" - return 1 - fi -} - -test_retrieve_raw() { - local id="test-retrieve_simple" - - imag-store create -p ${id} || { err "create failed"; return 1; } - - out "Going to test the retrieve functionality now" - local both_out="$(retrieve --id ${id} --raw)" - out "Retrieving for both_out finished" - - if [[ "$both_out" != "$(std_header)" ]]; then - err "Expected "$(std_header)" as output, got '$both_out'" - return 1 - fi -} - -invoke_tests \ - test_retrieve_nothing \ - test_retrieve_content \ - test_retrieve_header \ - test_retrieve_raw diff --git a/bin/core/imag-store/tests/003-delete_test.sh b/bin/core/imag-store/tests/003-delete_test.sh deleted file mode 100644 index a3d890e5..00000000 --- a/bin/core/imag-store/tests/003-delete_test.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -source $(dirname ${BASH_SOURCE[0]})/../../tests/utils.sh -source $(dirname ${BASH_SOURCE[0]})/utils.sh - -create() { - imag-store create $* -} - -delete() { - imag-store delete $* -} - -test_delete_simple() { - local name="test" - - create -p $name - delete --id $name - - local n=$($(find ${STORE}/ -type f | wc -l)) - if [[ $n -eq 0 ]]; then - success "Deleting worked" - else - err "There are still $n files in the store" - fi -} - -invoke_tests \ - test_delete_simple - diff --git a/bin/core/imag-store/tests/Makefile b/bin/core/imag-store/tests/Makefile deleted file mode 100644 index c58562d7..00000000 --- a/bin/core/imag-store/tests/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -ECHO=$(shell which echo) -e -TARGETS=$(shell find -name "*test.sh" -type f) -BASH=$(shell which bash) - -all: $(TARGETS) - @$(ECHO) $(TARGETS) - -$(TARGETS): %: .FORCE - @$(ECHO) "\t[BASH ]:\t$@" - @$(BASH) $@ - -.FORCE: - - diff --git a/bin/core/imag-store/tests/utils.sh b/bin/core/imag-store/tests/utils.sh deleted file mode 100644 index 60be71aa..00000000 --- a/bin/core/imag-store/tests/utils.sh +++ /dev/null @@ -1,6 +0,0 @@ -source $(dirname ${BASH_SOURCE[0]})/../../tests/utils.sh - -imag-store() { - imag-call-binary "$(dirname ${BASH_SOURCE[0]})/../../target/debug/" imag-store $* -} - diff --git a/tests/utils.sh b/tests/utils.sh deleted file mode 100644 index 57c5b079..00000000 --- a/tests/utils.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env bash - -# -# -# This file contains test utility functions which are used by the test scripts -# for each binary. -# -# - - -COLOR_OFF='\e[0m' # Text Reset -RED='\e[0;31m' # Red -YELLOW='\e[0;33m' # Yellow -GREEN='\e[0;32m' # Green - -RUNTIME="/tmp" -STORE="${RUNTIME}/store" - -out() { - [[ -z "$DEBUG_OUTPUT_OFF" ]] && echo -e "${YELLOW}:: $*${COLOR_OFF}" -} - -success() { - [[ -z "$DEBUG_OUTPUT_OFF" ]] && echo -e "${GREEN}>> $*${COLOR_OFF}" -} - -err() { - [[ -z "$DEBUG_OUTPUT_OFF" ]] && echo -e "${RED}!! $*${COLOR_OFF}" -} - -silent() { - DEBUG_OUTPUT_OFF=1 $* -} - -imag-call-binary() { - local searchdir=$1; shift - local binary=$1; shift - [[ -d $searchdir ]] || { err "FATAL: No directory $searchdir"; exit 1; } - local bin=$(find $searchdir -iname $binary -type f -executable) - local flags="--no-color --config ./imagrc.toml --override-config store.implicit-create=true --rtp $RUNTIME" - out "Calling '$bin $flags $*'" - $bin $flags $* -} - -cat_entry() { - cat ${STORE}/$1 -} - -reset_store() { - rm -rf "${STORE}"/.git - rm -r "${STORE}" -} - -call_test() { - prepare_store_directory || { - err "Preparing store directory failed" - exit 1 - } - - out "-- TESTING: '$1' --" - $1 - result=$? - if [[ -z "$DONT_RESET_STORE" ]]; then - out "Reseting store" - reset_store - out "Store reset done" - fi - [[ $result -eq 0 ]] || { err "-- FAILED: '$1'. Exiting."; exit 1; } - success "-- SUCCESS: '$1' --" -} - -__git() { - out "Calling git: $*" - git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git $* -} - -__git_commit() { - out "Calling git-commit: $*" - git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git commit -m "$*" -} - -prepare_store_directory() { - out "Preparing /tmp/store" - mkdir -p /tmp/store/ &&\ - touch /tmp/store/.gitkeep &&\ - __git init &&\ - __git config --local user.email "imag@imag-pim.org" &&\ - __git config --local user.name "Imag CI" &&\ - __git add .gitkeep &&\ - __git_commit 'Initial commit: .gitkeep' -} - -invoke_tests() { - out "Invoking tests." - if [[ ! -z "$INVOKE_TEST" ]]; then - out "Invoking only $INVOKE_TEST" - call_test "$INVOKE_TEST" - else - out "Invoking $*" - for t in $*; do - call_test "$t" - done - fi -} - - |