Merge pull request #708 from matthiasbeyer/imag-link/test-fixup
Imag link/test fixup
This commit is contained in:
commit
06038b8405
2 changed files with 52 additions and 16 deletions
|
@ -31,13 +31,13 @@ mktestentry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_link_modificates() {
|
test_link_modificates() {
|
||||||
mktestentry "test~0.2.0"
|
mktestentry "test"
|
||||||
mktestentry "test2~0.2.0"
|
mktestentry "test2"
|
||||||
|
|
||||||
imag-link internal add --from "test~0.2.0" --to "test2~0.2.0"
|
imag-link internal add --from "test" --to "test2"
|
||||||
|
|
||||||
if [[ "$(default_entry)" -eq "$(cat_entry 'test~0.2.0')" ]] ||
|
if [ "$(default_entry)" == "$(cat_entry 'test')" ] ||
|
||||||
[[ "$(default_entry)" -eq "$(cat_entry 'test2~0.2.0')" ]]
|
[ "$(default_entry)" == "$(cat_entry 'test2')" ]
|
||||||
then
|
then
|
||||||
err "Entry was unmodified after linking"
|
err "Entry was unmodified after linking"
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -45,25 +45,56 @@ test_link_modificates() {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_linking_links() {
|
test_linking_links() {
|
||||||
mktestentry "test~0.2.0"
|
mktestentry "test"
|
||||||
mktestentry "test2~0.2.0"
|
mktestentry "test2"
|
||||||
|
|
||||||
imag-link internal add --from "test~0.2.0" --to "test2~0.2.0"
|
imag-link internal add --from "test" --to "test2"
|
||||||
|
|
||||||
if [[ "$(entry_linked_to '/test~0.2.0')" == "$(cat_entry 'test2~0.2.0')" ]];
|
if [[ "$(entry_linked_to '"test"')" != "$(cat_entry 'test2')" ]];
|
||||||
then
|
then
|
||||||
err "Linking to 'test~0.2.0' didn't succeed for 'test2~0.2.0'"
|
err "Linking to 'test' didn't succeed for 'test2'"
|
||||||
err $(cat_entry 'test2~0.2.0')
|
err "\n$(cat_entry 'test2')\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$(entry_linked_to '/test2~0.2.0')" == "$(cat_entry 'test~0.2.0')" ]];
|
if [[ "$(entry_linked_to '"test2"')" != "$(cat_entry 'test')" ]];
|
||||||
then
|
then
|
||||||
err "Linking to 'test2~0.2.0' didn't succeed for 'test~0.2.0'"
|
err "Linking to 'test2' didn't succeed for 'test'"
|
||||||
err $(cat_entry 'test~0.2.0')
|
err "\n$(cat_entry 'test')\n"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
test_multilinking() {
|
||||||
|
mktestentry "test"
|
||||||
|
mktestentry "test2"
|
||||||
|
|
||||||
|
imag-link internal add --from "test" --to "test2" || {
|
||||||
|
err "Linking failed"; return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
imag-link internal add --from "test" --to "test2" || {
|
||||||
|
err "Linking again failed"; return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
local linked_to_test="$(entry_linked_to '"test"' | sha1sum)"
|
||||||
|
local linked_to_test2="$(entry_linked_to '"test2"' | sha1sum)"
|
||||||
|
local t2="$(cat_entry 'test2' | sha1sum)"
|
||||||
|
local t1="$(cat_entry 'test' | sha1sum)"
|
||||||
|
|
||||||
|
if [ "${linked_to_test}" != "${t2}" ];
|
||||||
|
then
|
||||||
|
err "Linking twice to 'test' didn't result in the expected output for 'test2'"
|
||||||
|
err "\n$(cat_entry 'test2')\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${linked_to_test2}" != "${t1}" ];
|
||||||
|
then
|
||||||
|
err "Linking twice to 'test2' didn't result in the expected output for 'test'"
|
||||||
|
err "\n$(cat_entry 'test')\n"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
invoke_tests \
|
invoke_tests \
|
||||||
test_link_modificates \
|
test_link_modificates \
|
||||||
test_linking_links
|
test_linking_links \
|
||||||
|
test_multilinking
|
||||||
|
|
||||||
|
|
|
@ -100,8 +100,13 @@ impl InternalLinker for Entry {
|
||||||
fn links_into_values(links: Vec<StoreId>) -> Vec<Result<Value>> {
|
fn links_into_values(links: Vec<StoreId>) -> Vec<Result<Value>> {
|
||||||
links
|
links
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.unique()
|
|
||||||
.map(|s| s.without_base().to_str().map_err_into(LEK::InternalConversionError))
|
.map(|s| s.without_base().to_str().map_err_into(LEK::InternalConversionError))
|
||||||
|
.unique_by(|entry| {
|
||||||
|
match entry {
|
||||||
|
&Ok(ref e) => Some(e.clone()),
|
||||||
|
&Err(_) => None,
|
||||||
|
}
|
||||||
|
})
|
||||||
.map(|elem| elem.map(Value::String))
|
.map(|elem| elem.map(Value::String))
|
||||||
.sorted_by(|a, b| {
|
.sorted_by(|a, b| {
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
|
|
Loading…
Reference in a new issue