2016-02-04 16:57:35 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-04-14 15:22:47 +00:00
|
|
|
source $(dirname ${BASH_SOURCE[0]})/../../tests/utils.sh
|
2016-02-04 16:57:35 +00:00
|
|
|
source $(dirname ${BASH_SOURCE[0]})/utils.sh
|
|
|
|
|
|
|
|
std_header() {
|
|
|
|
cat <<EOS
|
|
|
|
---
|
|
|
|
[imag]
|
|
|
|
links = []
|
2017-02-04 11:17:48 +00:00
|
|
|
version = "0.3.0"
|
2016-02-04 16:57:35 +00:00
|
|
|
---
|
|
|
|
EOS
|
|
|
|
}
|
|
|
|
|
|
|
|
retrieve() {
|
|
|
|
silent imag-store retrieve $*
|
|
|
|
}
|
|
|
|
|
|
|
|
test_retrieve_nothing() {
|
2016-09-04 22:36:45 +00:00
|
|
|
local id="test-retrieve_nothing"
|
2016-02-04 16:57:35 +00:00
|
|
|
|
2016-08-26 11:41:50 +00:00
|
|
|
imag-store create -p ${id} || { err "create failed"; return 1; }
|
2016-02-04 16:57:35 +00:00
|
|
|
|
|
|
|
out "Going to test the retrieve functionality now"
|
2016-09-06 07:32:05 +00:00
|
|
|
local zero_out="$(retrieve --id ${id})" || return 1
|
2016-02-04 16:57:35 +00:00
|
|
|
out "Retrieving for zero_out finished"
|
|
|
|
|
|
|
|
if [[ ! -z "$zero_out" ]]; then
|
|
|
|
err "Expected zero output, got '$zero_out'"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
test_retrieve_content() {
|
2016-09-04 22:36:45 +00:00
|
|
|
local id="test-retrieve_simple"
|
2016-02-04 16:57:35 +00:00
|
|
|
|
2016-08-26 11:41:50 +00:00
|
|
|
imag-store create -p ${id} || { err "create failed"; return 1; }
|
2016-02-04 16:57:35 +00:00
|
|
|
|
|
|
|
out "Going to test the retrieve functionality now"
|
|
|
|
|
2016-09-06 07:32:05 +00:00
|
|
|
local content_out="$(retrieve --id ${id} --content)" || return 1
|
2016-02-04 16:57:35 +00:00
|
|
|
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() {
|
2016-09-04 22:36:45 +00:00
|
|
|
local id="test-retrieve_simple"
|
2016-02-04 16:57:35 +00:00
|
|
|
|
2016-08-26 11:41:50 +00:00
|
|
|
imag-store create -p ${id} || { err "create failed"; return 1; }
|
2016-02-04 16:57:35 +00:00
|
|
|
|
|
|
|
out "Going to test the retrieve functionality now"
|
2016-09-04 22:36:45 +00:00
|
|
|
local header_out="$(retrieve --id ${id} --header)"
|
2016-02-04 16:57:35 +00:00
|
|
|
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() {
|
2016-09-04 22:36:45 +00:00
|
|
|
local id="test-retrieve_simple"
|
2016-02-04 16:57:35 +00:00
|
|
|
|
2016-08-26 11:41:50 +00:00
|
|
|
imag-store create -p ${id} || { err "create failed"; return 1; }
|
2016-02-04 16:57:35 +00:00
|
|
|
|
|
|
|
out "Going to test the retrieve functionality now"
|
2016-08-26 11:41:50 +00:00
|
|
|
local both_out="$(retrieve --id ${id} --raw)"
|
2016-02-04 16:57:35 +00:00
|
|
|
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
|