Skip to content

Commit

Permalink
chore: update shopware install script
Browse files Browse the repository at this point in the history
  • Loading branch information
janosmiko committed Nov 29, 2024
1 parent 11f1fad commit 368c5bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 8 additions & 1 deletion images/_php-fpm-common/shopware-web/bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,14 @@ shopware_admin_user_exists() {
return 0
fi

if console user:list --json 2>/dev/null | jq -e ".[] | select(.username == \"${SHOPWARE_USERNAME:-admin}\")" >/dev/null; then
# If console user:list command is not available, return 0
if ! console user:list --json 2>/dev/null; then
return 0
fi


if console user:list --json 2>/dev/null |
} jq -e ".[] | select(.username == \"${SHOPWARE_USERNAME:-admin}\")" >/dev/null; then
return 0
fi

Expand Down
11 changes: 7 additions & 4 deletions images/_php-fpm-common/shopware-web/bin/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ EOF
]
EOF
assert_exit_code 1 "$(shopware_admin_user_exists)"

mock console false
assert_exit_code 0 "$(shopware_admin_user_exists)"
}

function test_shopware_admin_user() {
Expand All @@ -585,18 +588,18 @@ function test_shopware_admin_user() {
unset SHOPWARE_EMAIL
unset SHOPWARE_PASSWORD

# Below Shopware 6.5 it should not fail even if the console command exits with a non-zero exit code
# Below Shopware 6.6 it should not fail even if the console command exits with a non-zero exit code
mock shopware_admin_user_exists true
mock shopware_version echo "v6.4.0.0"
mock shopware_version echo "v6.5.0.0"
mock console false
spy true
shopware_admin_user
assert_exit_code 0 "$(shopware_admin_user)"
assert_have_been_called true

# Above Shopware 6.5 it should just change the password
# Above Shopware 6.6 it should just change the password
mock shopware_admin_user_exists true
mock shopware_version echo "v6.5.0.0"
mock shopware_version echo "v6.6.0.0"
spy console
shopware_admin_user
assert_have_been_called_with "user:change-password admin --password=ASDqwe123" console
Expand Down

0 comments on commit 368c5bd

Please sign in to comment.