-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api.sh
More file actions
executable file
·53 lines (46 loc) · 2.34 KB
/
test_api.sh
File metadata and controls
executable file
·53 lines (46 loc) · 2.34 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
SVC_PORT=3001
function curl_call()
{
svc_port=$SVC_PORT
method=""
if [[ "$1" == "GET" ]] || \
[[ "$1" == "PUT" ]] || \
[[ "$1" == "POST" ]] || \
[[ "$1" == "DELETE" ]]; then
method="-X $1"
shift 1
fi
route=$1
shift 1
data_args=""
if [[ $# -ge 1 ]]; then
data_args="-d $*"
fi
>&2 echo "Running: curl -s http://localhost:$svc_port/api/$route $method -H 'Content-Type: application/json' -d '$*'"
curl -s http://localhost:$svc_port/api/$route $method \
-H 'Content-Type: application/json' \
"$data_args" | jq
>&2 echo -e "\n"
}
function curl_to_file()
{
outfile=$1
shift 1
curl_call $* | tee $outfile.json
}
# curl_to_file ./sample.forks.topics_repos POST topic_repo_stats '{"month": 12, "year": 2023, "sort_by": "forks", "max_topic_rank": 20, "max_repo_rank":100}'
curl_to_file /tmp/t POST topic_repo_stats '{"month": 10, "year": 2023, "sort_by": "forks", "max_topic_rank": 10, "max_repo_rank":50}'
# # Sort order: forks
# curl_to_file ./sample.forks.topics_ranked POST topics '{"month": 12, "year": 2023, "sort_by": "forks", "max_rank": 10}'
# curl_to_file ./sample.forks.repos_ranked POST repos '{"month": 12, "year": 2023, "sort_by": "forks", "max_rank": 10}'
# curl_to_file ./sample.forks.langs_ranked POST languages '{"month": 12, "year": 2023, "sort_by": "forks", "max_rank": 10}'
# curl_to_file ./sample.forks.topics_repos POST topic_repo_stats '{"month": 12, "year": 2023, "sort_by": "forks", "max_topic_rank": 10, "max_repo_rank":10}'
# curl_to_file ./sample.forks.topics_langs POST topic_lang_stats '{"month": 12, "year": 2023, "sort_by": "forks", "max_topic_rank": 10, "max_lang_rank": 10}'
#
# # Sort order: stars
# curl_to_file ./sample.stars.topics_ranked POST topics '{"month": 12, "year": 2023, "sort_by": "stars", "max_rank": 10}'
# curl_to_file ./sample.stars.repos_ranked POST repos '{"month": 12, "year": 2023, "sort_by": "stars", "max_rank": 10}'
# curl_to_file ./sample.stars.langs_ranked POST languages '{"month": 12, "year": 2023, "sort_by": "stars", "max_rank": 10}'
# curl_to_file ./sample.stars.topics_repos POST topic_repo_stats '{"month": 12, "year": 2023, "sort_by": "stars", "max_topic_rank": 10, "max_repo_rank":10}'
# curl_to_file ./sample.stars.topics_langs POST topic_lang_stats '{"month": 12, "year": 2023, "sort_by": "stars", "max_topic_rank": 10, "max_lang_rank": 10}'