add automated testing script for user table
This commit is contained in:
parent
c2104fd9cc
commit
b96ba3eb34
|
@ -0,0 +1,58 @@
|
|||
#!/bin/sh
|
||||
|
||||
HOST=$1
|
||||
|
||||
if [ -z HOST ]; then
|
||||
echo "Host not specified, exiting"
|
||||
exit 1;
|
||||
fi;
|
||||
|
||||
echo -n 'Resetting DB...'
|
||||
|
||||
curl -X GET -f -s \
|
||||
http://$HOST:12402/reset_users_because_postman_is_dumb_like_that > /dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo 'Exiting due to previous error'
|
||||
exit 1
|
||||
fi
|
||||
echo ' Done.'
|
||||
|
||||
echo -n 'Creating users...'
|
||||
for i in $(seq 9); do
|
||||
curl -X POST -f -s \
|
||||
--data "{\"name\": \"hi$i\"}" \
|
||||
--header "Content-Type: application/json" \
|
||||
http://$HOST:12402/user > /dev/null;
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo 'Exiting due to previous error'
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo ' Done.'
|
||||
|
||||
echo -n 'Getting user UUID to delete...'
|
||||
DELETION_UUID=$(curl -X GET -f -s \
|
||||
http://$HOST:12402/users \
|
||||
| jq .[0].uuid);
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo 'Exiting due to previous error'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DELETION_UUID=${DELETION_UUID#\"}
|
||||
DELETION_UUID=${DELETION_UUID%\"}
|
||||
|
||||
echo " $DELETION_UUID."
|
||||
|
||||
echo -n "Deleting user $DELETION_UUID..."
|
||||
curl -X DELETE -f -s \
|
||||
http://127.0.0.1:12402/user/$DELETION_UUID > /dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo 'Exiting due to previous error'
|
||||
exit 1
|
||||
fi
|
||||
echo ' Done.'
|
Loading…
Reference in New Issue