123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- #!/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.3.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.3.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.3.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.3.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.3.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
|