-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_liveitems_api.sh
More file actions
executable file
·194 lines (154 loc) · 4.91 KB
/
Copy pathtest_liveitems_api.sh
File metadata and controls
executable file
·194 lines (154 loc) · 4.91 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/bin/bash
# Test script for Liveitems API endpoints
# Make sure your Laravel server is running on localhost:8000
BASE_URL="http://localhost:8000/api"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
print_test() {
echo -e "${BLUE}=== $1 ===${NC}"
}
print_success() {
echo -e "${GREEN}✓ $1${NC}"
}
print_error() {
echo -e "${RED}✗ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠ $1${NC}"
}
echo "📻 Testing Liveitems API Endpoints"
echo "==================================="
echo ""
# Test 1: Get individual liveitem
print_test "Testing Get Individual Liveitem"
echo "1.1 Get liveitem by ID 1"
curl -s "$BASE_URL/liveitem/1" | jq .
echo ""
echo "1.2 Get liveitem by ID 2"
curl -s "$BASE_URL/liveitem/2" | jq .
echo ""
echo "1.3 Get non-existent liveitem"
curl -s "$BASE_URL/liveitem/999999" | jq .
echo ""
echo "1.4 Get liveitem with invalid ID"
curl -s "$BASE_URL/liveitem/invalid" | jq .
echo ""
# Test 2: Get newest liveitems
print_test "Testing Get Newest Liveitems"
echo "2.1 Get newest liveitems"
curl -s "$BASE_URL/newest-liveitems" | jq .
echo ""
echo "2.2 Get newest liveitems with pagination"
curl -s "$BASE_URL/newest-liveitems?page=1&per_page=5" | jq .
echo ""
# Test 3: Get liveitem images
print_test "Testing Get Liveitem Images"
echo "3.1 Get images from liveitem 1"
curl -s "$BASE_URL/liveitem/1/images" | jq .
echo ""
echo "3.2 Get images from liveitem 2"
curl -s "$BASE_URL/liveitem/2/images" | jq .
echo ""
# Test 4: Get liveitem persons
print_test "Testing Get Liveitem Persons"
echo "4.1 Get persons from liveitem 1"
curl -s "$BASE_URL/liveitem/1/persons" | jq .
echo ""
echo "4.2 Get persons from liveitem 2"
curl -s "$BASE_URL/liveitem/2/persons" | jq .
echo ""
# Test 5: Get liveitem funding
print_test "Testing Get Liveitem Funding"
echo "5.1 Get funding from liveitem 1"
curl -s "$BASE_URL/liveitem/1/funding" | jq .
echo ""
echo "5.2 Get funding from liveitem 2"
curl -s "$BASE_URL/liveitem/2/funding" | jq .
echo ""
# Test 6: Get liveitem soundbites
print_test "Testing Get Liveitem Soundbites"
echo "6.1 Get soundbites from liveitem 1"
curl -s "$BASE_URL/liveitem/1/soundbites" | jq .
echo ""
echo "6.2 Get soundbites from liveitem 2"
curl -s "$BASE_URL/liveitem/2/soundbites" | jq .
echo ""
# Test 7: Get liveitem location
print_test "Testing Get Liveitem Location"
echo "7.1 Get location from liveitem 1"
curl -s "$BASE_URL/liveitem/1/location" | jq .
echo ""
echo "7.2 Get location from liveitem 2"
curl -s "$BASE_URL/liveitem/2/location" | jq .
echo ""
# Test 8: Different response formats
print_test "Testing Different Response Formats"
echo "8.1 Get liveitem 1 in JSON format"
curl -s -H "Accept: application/json" "$BASE_URL/liveitem/1" | jq .
echo ""
echo "8.2 Get liveitem 1 in XML format"
curl -s -H "Accept: application/xml" "$BASE_URL/liveitem/1"
echo ""
echo ""
echo "8.3 Get liveitem 1 in CSV format"
curl -s -H "Accept: text/csv" "$BASE_URL/liveitem/1"
echo ""
echo ""
# Test 9: Error scenarios
print_test "Testing Error Scenarios"
echo "9.1 Test with invalid liveitem ID"
curl -s "$BASE_URL/liveitem/invalid_id" | jq .
echo ""
echo "9.2 Test with negative ID"
curl -s "$BASE_URL/liveitem/-1" | jq .
echo ""
echo "9.3 Test with zero ID"
curl -s "$BASE_URL/liveitem/0" | jq .
echo ""
# Test 10: Metadata endpoints error handling
print_test "Testing Metadata Endpoints Error Handling"
echo "10.1 Get images from non-existent liveitem"
curl -s "$BASE_URL/liveitem/999999/images" | jq .
echo ""
echo "10.2 Get persons from non-existent liveitem"
curl -s "$BASE_URL/liveitem/999999/persons" | jq .
echo ""
echo "10.3 Get funding from non-existent liveitem"
curl -s "$BASE_URL/liveitem/999999/funding" | jq .
echo ""
echo "10.4 Get soundbites from non-existent liveitem"
curl -s "$BASE_URL/liveitem/999999/soundbites" | jq .
echo ""
echo "10.5 Get location from non-existent liveitem"
curl -s "$BASE_URL/liveitem/999999/location" | jq .
echo ""
# Test 11: Pagination testing for newest liveitems
print_test "Testing Pagination for Newest Liveitems"
echo "11.1 Page 1 with 3 items per page"
curl -s "$BASE_URL/newest-liveitems?page=1&per_page=3" | jq .
echo ""
echo "11.2 Page 2 with 3 items per page"
curl -s "$BASE_URL/newest-liveitems?page=2&per_page=3" | jq .
echo ""
echo "11.3 Invalid page number"
curl -s "$BASE_URL/newest-liveitems?page=0&per_page=5" | jq .
echo ""
echo "11.4 Very large per_page (should be limited)"
curl -s "$BASE_URL/newest-liveitems?page=1&per_page=1000" | jq .
echo ""
echo "==================================="
echo "🎉 Liveitems API Testing Complete!"
echo ""
echo "Summary:"
echo "- Tested individual liveitem retrieval"
echo "- Tested newest liveitems listing"
echo "- Tested liveitem metadata endpoints (images, persons, funding, etc.)"
echo "- Tested error handling"
echo "- Tested different response formats"
echo "- Tested pagination"
echo ""
echo "Note: Some endpoints may return 404 if test data doesn't exist"