fix(package): migrator: index_of subshell issue
This commit is contained in:
17
test/package/migrator/test/function-generate-word.sh
Normal file
17
test/package/migrator/test/function-generate-word.sh
Normal 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"
|
||||
47
test/package/migrator/test/function-index-of.sh
Normal file
47
test/package/migrator/test/function-index-of.sh
Normal 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"
|
||||
17
test/package/migrator/test/function-migration-list/run.sh
Normal file
17
test/package/migrator/test/function-migration-list/run.sh
Normal 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"
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE profile ADD COLUMN info TEXT;
|
||||
Reference in New Issue
Block a user