|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Output file |
| 4 | +output_file="test_list_api_results.txt" |
| 5 | + |
| 6 | +cd .. || { echo "Failed to navigate to parent directory."; exit 1; } |
| 7 | +go run populate.go || { echo "Failed to populate database."; exit 1; } |
| 8 | +cd - || { echo "Failed to navigate back."; exit 1; } |
| 9 | + |
| 10 | +# Clear the output file |
| 11 | +> "$output_file" |
| 12 | + |
| 13 | +# List of curl commands |
| 14 | +requests=( |
| 15 | +"GET http://localhost:8080/questions" |
| 16 | +"GET http://localhost:8080/questions?offset=10" |
| 17 | +"GET http://localhost:8080/questions?title=Reverse%20a%20String" |
| 18 | +"GET http://localhost:8080/questions?complexity=easy,medium" |
| 19 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures" |
| 20 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&complexity=easy,medium" |
| 21 | +"GET http://localhost:8080/questions?categories=Algorithms,Strings&title=Reverse%20a%20String" |
| 22 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String" |
| 23 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&categories=Algorithms,Strings" |
| 24 | +"GET http://localhost:8080/questions?sortField=title&sortValue=asc&offset=10" |
| 25 | +"GET http://localhost:8080/questions?sortField=title&sortValue=desc&offset=10" |
| 26 | +"GET http://localhost:8080/questions?sortField=createdAt&sortValue=asc&offset=10" |
| 27 | +"GET http://localhost:8080/questions?sortField=createdAt&sortValue=desc&offset=10" |
| 28 | +"GET http://localhost:8080/questions?sortField=complexity&sortValue=asc&offset=10" |
| 29 | +"GET http://localhost:8080/questions?sortField=complexity&sortValue=desc&offset=10" |
| 30 | +"GET http://localhost:8080/questions?sortField=id&sortValue=asc&offset=10" |
| 31 | +"GET http://localhost:8080/questions?sortField=id&sortValue=desc&offset=10" |
| 32 | +"GET http://localhost:8080/questions?limit=5" |
| 33 | +"GET http://localhost:8080/questions?limit=5&offset=10" |
| 34 | +"GET http://localhost:8080/questions?title=Reverse%20a%20String&sortField=complexity&sortValue=asc" |
| 35 | +"GET http://localhost:8080/questions?title=Reverse%20a%20String&sortField=complexity&sortValue=desc" |
| 36 | +"GET http://localhost:8080/questions?complexity=easy,medium&sortField=complexity&sortValue=asc" |
| 37 | +"GET http://localhost:8080/questions?complexity=easy,medium&sortField=complexity&sortValue=desc" |
| 38 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&sortField=complexity&sortValue=asc" |
| 39 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&sortField=complexity&sortValue=desc" |
| 40 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&complexity=easy,medium&sortField=complexity&sortValue=asc" |
| 41 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&complexity=easy,medium&sortField=complexity&sortValue=desc" |
| 42 | +"GET http://localhost:8080/questions?categories=Algorithms,Strings&title=Reverse%20a%20String&sortField=complexity&sortValue=asc" |
| 43 | +"GET http://localhost:8080/questions?categories=Algorithms,Strings&title=Reverse%20a%20String&sortField=complexity&sortValue=desc" |
| 44 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&sortField=complexity&sortValue=asc" |
| 45 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&sortField=complexity&sortValue=desc" |
| 46 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&categories=Algorithms,Strings&sortField=complexity&sortValue=asc" |
| 47 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&categories=Algorithms,Strings&sortField=complexity&sortValue=desc" |
| 48 | +"GET http://localhost:8080/questions?title=Reverse%20a%20String&sortField=createdAt&sortValue=asc" |
| 49 | +"GET http://localhost:8080/questions?title=Reverse%20a%20String&sortField=createdAt&sortValue=desc" |
| 50 | +"GET http://localhost:8080/questions?complexity=easy,medium&sortField=createdAt&sortValue=asc" |
| 51 | +"GET http://localhost:8080/questions?complexity=easy,medium&sortField=createdAt&sortValue=desc" |
| 52 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&sortField=createdAt&sortValue=asc" |
| 53 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&sortField=createdAt&sortValue=desc" |
| 54 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&complexity=easy,medium&sortField=createdAt&sortValue=asc" |
| 55 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&complexity=easy,medium&sortField=createdAt&sortValue=desc" |
| 56 | +"GET http://localhost:8080/questions?categories=Algorithms,Strings&title=Reverse%20a%20String&sortField=createdAt&sortValue=asc" |
| 57 | +"GET http://localhost:8080/questions?categories=Algorithms,Strings&title=Reverse%20a%20String&sortField=createdAt&sortValue=desc" |
| 58 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&sortField=createdAt&sortValue=asc" |
| 59 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&sortField=createdAt&sortValue=desc" |
| 60 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&categories=Algorithms,Strings&sortField=createdAt&sortValue=asc" |
| 61 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&categories=Algorithms,Strings&sortField=createdAt&sortValue=desc" |
| 62 | +"GET http://localhost:8080/questions?title=Reverse%20a%20String&sortField=id&sortValue=asc" |
| 63 | +"GET http://localhost:8080/questions?title=Reverse%20a%20String&sortField=id&sortValue=desc" |
| 64 | +"GET http://localhost:8080/questions?complexity=easy,medium&sortField=id&sortValue=asc" |
| 65 | +"GET http://localhost:8080/questions?complexity=easy,medium&sortField=id&sortValue=desc" |
| 66 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&sortField=id&sortValue=asc" |
| 67 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&sortField=id&sortValue=desc" |
| 68 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&complexity=easy,medium&sortField=id&sortValue=asc" |
| 69 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&complexity=easy,medium&sortField=id&sortValue=desc" |
| 70 | +"GET http://localhost:8080/questions?categories=Algorithms,Strings&title=Reverse%20a%20String&sortField=id&sortValue=asc" |
| 71 | +"GET http://localhost:8080/questions?categories=Algorithms,Strings&title=Reverse%20a%20String&sortField=id&sortValue=desc" |
| 72 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&sortField=id&sortValue=asc" |
| 73 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&sortField=id&sortValue=desc" |
| 74 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&categories=Algorithms,Strings&sortField=id&sortValue=asc" |
| 75 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&categories=Algorithms,Strings&sortField=id&sortValue=desc" |
| 76 | +"GET http://localhost:8080/questions?title=Reverse%20a%20String&sortField=title&sortValue=asc" |
| 77 | +"GET http://localhost:8080/questions?title=Reverse%20a%20String&sortField=title&sortValue=desc" |
| 78 | +"GET http://localhost:8080/questions?complexity=easy,medium&sortField=title&sortValue=asc" |
| 79 | +"GET http://localhost:8080/questions?complexity=easy,medium&sortField=title&sortValue=desc" |
| 80 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&sortField=title&sortValue=asc" |
| 81 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&sortField=title&sortValue=desc" |
| 82 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&complexity=easy,medium&sortField=title&sortValue=asc" |
| 83 | +"GET http://localhost:8080/questions?categories=Algorithms,Data%20Structures&complexity=easy,medium&sortField=title&sortValue=desc" |
| 84 | +"GET http://localhost:8080/questions?categories=Algorithms,Strings&title=Reverse%20a%20String&sortField=title&sortValue=asc" |
| 85 | +"GET http://localhost:8080/questions?categories=Algorithms,Strings&title=Reverse%20a%20String&sortField=title&sortValue=desc" |
| 86 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&sortField=title&sortValue=asc" |
| 87 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&sortField=title&sortValue=desc" |
| 88 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&categories=Algorithms,Strings&sortField=title&sortValue=asc" |
| 89 | +"GET http://localhost:8080/questions?complexity=easy,medium&title=Reverse%20a%20String&categories=Algorithms,Strings&sortField=title&sortValue=desc" |
| 90 | +"GET http://localhost:8080/questions?complexity=InvalidComplexity" |
| 91 | +"GET http://localhost:8080/questions?InvalidFilterField=InvalidComplexity" |
| 92 | +"GET http://localhost:8080/questions?sortField=InvalidSortField&sortValue=asc" |
| 93 | +"GET http://localhost:8080/questions?sortField=complexity&&sortValue=InvalidSortValue" |
| 94 | +) |
| 95 | + |
| 96 | +# Execute each request and save the output to the file |
| 97 | +for request in "${requests[@]}"; do |
| 98 | + method=$(echo $request | cut -d' ' -f1) |
| 99 | + url=$(echo $request | cut -d' ' -f2) |
| 100 | + echo "Executing: $request" >> "$output_file" |
| 101 | + echo "Response:" >> "$output_file" |
| 102 | + curl -s -X $method "$url" >> "$output_file" |
| 103 | + echo -e "\n" >> "$output_file" |
| 104 | +done |
| 105 | + |
| 106 | +echo "All requests executed. Results saved in $output_file." |
0 commit comments