fix(package): migrator: index_of subshell issue

This commit is contained in:
2025-12-06 04:47:31 +00:00
parent 3b506a7888
commit 373a3fe3f0
8 changed files with 166 additions and 52 deletions

View File

@@ -0,0 +1,17 @@
# shellcheck disable=SC2034
AS_LIBRARY=
# shellcheck disable=SC1090
. "$(which migrator)"
log notice "test case: ${WHITE}generate word"
if ! answer=$(generate_word); then
log error "test failed: ${WHITE}error during generate_word call"
exit 1
fi
if [ "$(printf '%s' "$answer" | wc -c)" -ne 6 ]; then
log error "test failed: ${WHITE}word length must be 6 chars"
exit 1
fi
log notice "test passed"

View File

@@ -0,0 +1,47 @@
# shellcheck disable=SC2034
AS_LIBRARY=
# shellcheck disable=SC1090
. "$(which migrator)"
array='item1
item2
item3
item4
item5
item6
item7'
log notice "test case: ${WHITE}index of"
if ! answer=$(index_of "$array" 'item4'); then
log error "test failed: ${WHITE}error during index_of call"
exit 1
fi
is_number "$answer" >/dev/null || { log error "test failed: ${WHITE}answer not a number"; exit 1; }
if [ "$answer" -ne 4 ]; then
log error "test failed: ${WHITE}wrong answer"
exit 1
fi
log notice "test case: ${WHITE}error: item not found"
if answer=$(index_of "$array" 'item10'); then
log error "test failed: ${WHITE} must return an error"
exit 1
fi
log notice "test case: ${WHITE}one element"
array='20251104192425-add-info-to-profile'
item='20251104192425-add-info-to-profile'
if ! answer=$(index_of "$array" "$item"); then
log error "test failed: ${WHITE}error during index_of call"
exit 1
fi
if [ "$answer" -ne 1 ]; then
log error "test failed: ${WHITE}wrong answer"
exit 1
fi
log notice "test passed"

View File

@@ -0,0 +1,17 @@
# shellcheck disable=SC2034
AS_LIBRARY=
# shellcheck disable=SC1090
. "$(which migrator)"
log notice "test case: ${WHITE}migration list"
if ! answer=$(migration_list); then
log error "test failed: ${WHITE}error during migration_list call"
exit 1
fi
if [ "$answer" != "20251104192425-add-info-to-profile" ]; then
log error "test failed: ${WHITE}unexpected \`migration list\` answer"
exit 1
fi
log notice "test passed"

View File

@@ -0,0 +1 @@
ALTER TABLE profile ADD COLUMN info TEXT;