Last active
July 12, 2020 19:07
-
-
Save jinjagit/656be8a3f2f1dc26ceca2ff0a6fb885c to your computer and use it in GitHub Desktop.
bash file to test the curl command examples on https://liquidvoting.io/ (Linux friendly)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
tput init | |
echo Testing locally, on http://localhost:4000 ... | |
echo | |
response1=$(curl -X POST http://localhost:4000 -H "Content-Type: application/json" -H "Org-UUID: b7a9cae5-6e3a-48b1-8730-8b5c8d6c9b5a" -d '{ "query": "mutation { createDelegation(proposalUrl: \"https://github.com/user/repo/pulls/15\", delegatorEmail: \"[email protected]\", delegateEmail: \"[email protected]\") { delegator { email } delegate { email } proposalUrl }}" }') | |
pass1=$(echo "$response1" | grep -o '{"data":{"createDelegation":{"delegate":{"email":"[email protected]"},"delegator":{"email":"[email protected]"},"proposalUrl":"https://github.com/user/repo/pulls/15"}}}') | |
fail1=$(echo "$response1" | grep -o '"message":"Could not create delegation"') | |
if [ "$pass1" != "" ] | |
then tput setaf 2; echo "PASS: createDelegation succeeded." | |
elif [ "$fail1" != "" ] | |
then tput setaf 3; echo "ERROR: Could not create delegation. Try running 'ecto.reset' and restarting server." | |
echo response: | |
echo $response1 | |
else tput setaf 1; echo "FAIL: Run curl request manually to see details" | |
fi | |
tput init; echo | |
response2=$(curl -X POST http://localhost:4000 -H "Content-Type: application/json" -H "Org-UUID: b7a9cae5-6e3a-48b1-8730-8b5c8d6c9b5a" -d '{ "query": "mutation { createVote(participantEmail: \"[email protected]\", proposalUrl:\"https://github.com/user/repo/pulls/15\", yes: true) { participant { email } yes votingResult { inFavor against } } }" }') | |
pass2=$(echo "$response2" | grep -o '{"data":{"createVote":{"participant":{"email":"[email protected]"},"votingResult":{"against":0,"inFavor":2},"yes":true}}}') | |
fail2=$(echo "$response2" | grep -o '"message":"Could not create vote"') | |
if [ "$pass2" != "" ] | |
then tput setaf 2; echo "PASS: createVote & votingResult succeeded." | |
elif [ "$fail2" != "" ] | |
then tput setaf 3; echo "ERROR: Could not create vote. Try running 'ecto.reset' and restarting server." | |
echo response: | |
echo $response2 | |
else tput setaf 1; echo "FAIL: Run curl request manually to see details" | |
fi | |
tput init; echo | |
echo Testing remotely, https://api.liquidvoting.io ... | |
echo | |
response3=$(curl -X POST https://api.liquidvoting.io -H "Content-Type: application/json" -H "Authorization: Bearer 62309201-d2f0-407f-875b-9f836f94f2ca" -d '{ "query": "mutation { createDelegation(proposalUrl: \"https://github.com/user/repo/pulls/15\", delegatorEmail: \"[email protected]\", delegateEmail: \"[email protected]\") { delegator { email } delegate { email } proposalUrl }}" }') | |
pass3=$(echo "$response3" | grep -o '{"data":{"createDelegation":{"delegate":{"email":"[email protected]"},"delegator":{"email":"[email protected]"},"proposalUrl":"https://github.com/user/repo/pulls/15"}}}') | |
fail3=$(echo "$response3" | grep -o '"message":"Could not create delegation"') | |
if [ "$pass3" != "" ] | |
then tput setaf 2; echo "PASS: createDelegation succeeded." | |
elif [ "$fail3" != "" ] | |
then tput setaf 3; echo "ERROR: Could not create delegation. Try waiting X minutes for database reset." | |
echo response: | |
echo $response3 | |
else tput setaf 1; echo "FAIL: Run curl request manually to see details" | |
fi | |
tput init; echo | |
response4=$(curl -X POST https://api.liquidvoting.io -H "Content-Type: application/json" -H "Authorization: Bearer 62309201-d2f0-407f-875b-9f836f94f2ca" -d '{ "query": "mutation { createVote(participantEmail: \"[email protected]\", proposalUrl:\"https://github.com/user/repo/pulls/15\", yes: true) { participant { email } yes votingResult { inFavor against } } }" }') | |
pass4=$(echo "$response4" | grep -o '{"data":{"createVote":{"participant":{"email":"[email protected]"},"votingResult":{"against":0,"inFavor":2},"yes":true}}}') | |
fail4=$(echo "$response4" | grep -o '"message":"Could not create vote"') | |
echo $response4 | |
if [ "$pass4" != "" ] | |
then tput setaf 2; echo "PASS: createVote & votingResult succeeded." | |
elif [ "$fail4" != "" ] | |
then tput setaf 3; echo "ERROR: Could not create vote. Try waiting X minutes for database reset." | |
echo response: | |
echo $response4 | |
else tput setaf 1; echo "FAIL: Run curl request manually to see details" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Linux friendly:
For example, I'm not sure
tput
(text colors) is a thing on OSX.