Feat(medusa): Integration testing of cli (#1689)
* add initial testing files * prepare for github * remove empty files * remove ids * set user and password for postgres service * remove node setup * remove unused flag from yarn install * correct medusajs package * arguments for create-medusa project * make create command into one line * working directory update * update workflow * add build * run scripts from medusa-cli * move scripts to medusa-cli * add install * get server output * rename build to install * update login script to get feedback * add arguments to login script * add argument for directory to get-product * pass cli-test to get-products script * add wait command * fix waiting * update wait-for-server * echo status * update start testing * refactor code into test-action * add list config for testing * include shell * update get-products script * test to see if action fails when given wrong input * use custom action for testing devleopment server and extend waiting for server to spin up * update actions * remove cache version * yarn and build in cli-test directory * update core * update working directories * test working dir after cd up * update * fix directories * update directories * use setup server action * invoke correct action * test * update cli action * remove action * test with medusa-dev * remove medusa dev for now * test * include medusa-dev * remove invalid medusa new command * try moving project one dir up * add silent to curl output from live server wait * update seed data directory * test * remove sub workflow * add matrix and postgres override for medusa-config * fix matrix syntax * add database url to job * update yaml * cli should fail on logging in * create setup server action * update test-server * update scripts * run scripts directory instead of cli scripts * make directories current * remove tests from cli * run only on pr * update name * remove batch job model (for testing purposes) * remove ls from test server action * get content from develop * undo changes to generate reference * remove comments from scripts * test failing command * redo migrate command failing * move scripts into interation tests * Apply suggestions from code review Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
24
integration-tests/scripts/cli/get-products.sh
Executable file
24
integration-tests/scripts/cli/get-products.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
seedJson=$(pwd)/$1
|
||||
|
||||
res=$(curl -s 'http://localhost:9000/store/products' | \
|
||||
python3 -c "
|
||||
|
||||
import sys, json;
|
||||
|
||||
loadedProducts = json.load(sys.stdin)['products'];
|
||||
|
||||
seededProducts = json.load(open(\""$seedJson"\"))['products'];
|
||||
|
||||
result = set([product['title'] for product in loadedProducts]) == set([product['title'] for product in seededProducts])
|
||||
|
||||
print(result)
|
||||
")
|
||||
|
||||
if [[ "$res" != "True" ]] ; then
|
||||
echo "Seed failed, products are not equal"
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
15
integration-tests/scripts/cli/login.sh
Executable file
15
integration-tests/scripts/cli/login.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
status_code=$(curl \
|
||||
-X POST\
|
||||
-H "Content-Type: application/json"\
|
||||
-d '{"email":"'$1'", "password":"'$2'"}'\
|
||||
--write-out %{http_code}\
|
||||
http://localhost:9000/admin/auth)
|
||||
|
||||
if [[ "$status_code" -ne 200 ]] ; then
|
||||
echo "Site status changed to $status_code"
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
29
integration-tests/scripts/cli/wait-for-server-live.sh
Executable file
29
integration-tests/scripts/cli/wait-for-server-live.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
for i in {1..6}
|
||||
do
|
||||
echo $i
|
||||
status_code=$(curl \
|
||||
-X GET \
|
||||
--write-out %{http_code} \
|
||||
--silent\
|
||||
--output /dev/null\
|
||||
http://localhost:9000/store/products)
|
||||
|
||||
echo $status_code
|
||||
if [[ "$status_code" -ne 000 ]] ; then
|
||||
echo "exiting"
|
||||
exit 0
|
||||
else
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
|
||||
echo $status_code
|
||||
|
||||
if [[ "$status_code" = 000 ]] ; then
|
||||
echo "Site status changed to $status_code"
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
Reference in New Issue
Block a user