2016-04-14 15:39:05 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
source $(dirname ${BASH_SOURCE[0]})/../../tests/utils.sh
|
|
|
|
source $(dirname ${BASH_SOURCE[0]})/utils.sh
|
|
|
|
|
|
|
|
default_entry() {
|
|
|
|
cat <<EOS
|
|
|
|
---
|
|
|
|
[imag]
|
|
|
|
links = []
|
2016-07-12 09:51:20 +00:00
|
|
|
version = "0.2.0"
|
2016-04-14 15:39:05 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
EOS
|
|
|
|
}
|
|
|
|
|
2016-04-16 20:55:39 +00:00
|
|
|
entry_linked_to() {
|
|
|
|
cat <<EOS
|
|
|
|
---
|
|
|
|
[imag]
|
|
|
|
links = [$1]
|
2016-07-12 09:51:20 +00:00
|
|
|
version = "0.2.0"
|
2016-04-16 20:55:39 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
EOS
|
|
|
|
}
|
|
|
|
|
2016-04-14 15:39:05 +00:00
|
|
|
mktestentry() {
|
|
|
|
mkdir -p ${STORE}
|
|
|
|
default_entry > ${STORE}/$1
|
|
|
|
}
|
|
|
|
|
|
|
|
test_link_modificates() {
|
2016-07-12 09:51:20 +00:00
|
|
|
mktestentry "test~0.2.0"
|
|
|
|
mktestentry "test2~0.2.0"
|
2016-04-14 15:39:05 +00:00
|
|
|
|
2016-07-12 09:51:20 +00:00
|
|
|
imag-link internal add --from "test~0.2.0" --to "test2~0.2.0"
|
2016-04-14 15:39:05 +00:00
|
|
|
|
2016-07-12 09:51:20 +00:00
|
|
|
if [[ "$(default_entry)" -eq "$(cat_entry 'test~0.2.0')" ]] ||
|
|
|
|
[[ "$(default_entry)" -eq "$(cat_entry 'test2~0.2.0')" ]]
|
2016-04-14 15:39:05 +00:00
|
|
|
then
|
|
|
|
err "Entry was unmodified after linking"
|
|
|
|
return 1;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-04-16 20:55:39 +00:00
|
|
|
test_linking_links() {
|
2016-07-12 09:51:20 +00:00
|
|
|
mktestentry "test~0.2.0"
|
|
|
|
mktestentry "test2~0.2.0"
|
2016-04-16 20:55:39 +00:00
|
|
|
|
2016-07-12 09:51:20 +00:00
|
|
|
imag-link internal add --from "test~0.2.0" --to "test2~0.2.0"
|
2016-04-16 20:55:39 +00:00
|
|
|
|
2016-07-12 09:51:20 +00:00
|
|
|
if [[ "$(entry_linked_to '/test~0.2.0')" == "$(cat_entry 'test2~0.2.0')" ]];
|
2016-04-16 20:55:39 +00:00
|
|
|
then
|
2016-07-12 09:51:20 +00:00
|
|
|
err "Linking to 'test~0.2.0' didn't succeed for 'test2~0.2.0'"
|
|
|
|
err $(cat_entry 'test2~0.2.0')
|
2016-04-16 20:55:39 +00:00
|
|
|
fi
|
|
|
|
|
2016-07-12 09:51:20 +00:00
|
|
|
if [[ "$(entry_linked_to '/test2~0.2.0')" == "$(cat_entry 'test~0.2.0')" ]];
|
2016-04-16 20:55:39 +00:00
|
|
|
then
|
2016-07-12 09:51:20 +00:00
|
|
|
err "Linking to 'test2~0.2.0' didn't succeed for 'test~0.2.0'"
|
|
|
|
err $(cat_entry 'test~0.2.0')
|
2016-04-16 20:55:39 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-04-14 15:39:05 +00:00
|
|
|
invoke_tests \
|
2016-04-16 20:55:39 +00:00
|
|
|
test_link_modificates \
|
|
|
|
test_linking_links
|
2016-04-14 15:39:05 +00:00
|
|
|
|