-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·28 lines (25 loc) · 906 Bytes
/
test.sh
File metadata and controls
executable file
·28 lines (25 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
urlCountMap=(
"http://google.com:::617" # should error
"http://localhost:3000/queries/count/2015:::573697"
"http://localhost:3000/queries/count/1945:::0"
"http://localhost:3000/queries/count/abcdef:::0"
"http://localhost:3000/queries/count/2015-08:::573697"
"http://localhost:3000/queries/count/2015-08-03:::198117"
"http://localhost:3000/queries/count/2015-08-01%2000:04:::617"
)
for url in "${urlCountMap[@]}"; do
urlValue="${url%%:::*}"
urlCount="${url##*:::}"
response=$(curl -s -X GET "$( echo "$urlValue" | sed 's/ /%20/g' )")
if [[ $response =~ "count" ]]; then
actualCount=$(echo "${response}" | jq -r '.count')
if [[ "${actualCount}" -eq "${urlCount}" ]]; then
echo "✅ ${urlCount} = ${actualCount} - ${urlValue}"
else
echo "❌ ${urlCount} != ${actualCount} - ${urlValue}"
fi
else
echo "❌ Incorrect URL: ${url}"
fi
done