-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api.sh
More file actions
executable file
·49 lines (39 loc) · 1.75 KB
/
test-api.sh
File metadata and controls
executable file
·49 lines (39 loc) · 1.75 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
#!/bin/bash
# Weather API Test Script
# This script tests the weather API endpoints
BASE_URL="http://localhost:8080/api/weather"
echo "🌤️ Weather API Test Script"
echo "================================"
# Test 1: Get weather by coordinates (Berlin)
echo
echo "📍 Test 1: Get weather by coordinates (Berlin)"
echo "URL: $BASE_URL/current?latitude=52.5200&longitude=13.4050"
curl -s "$BASE_URL/current?latitude=52.5200&longitude=13.4050" | jq '.' || echo "❌ Test failed"
# Test 2: Get weather by city name
echo
echo "🏙️ Test 2: Get weather by city name (Berlin)"
echo "URL: $BASE_URL/current?city=Berlin"
curl -s "$BASE_URL/current?city=Berlin" | jq '.' || echo "❌ Test failed"
# Test 3: Invalid request - missing parameters
echo
echo "❌ Test 3: Invalid request - missing parameters"
echo "URL: $BASE_URL/current"
curl -s "$BASE_URL/current" | jq '.' || echo "Expected error response"
# Test 4: Invalid request - both parameters provided
echo
echo "❌ Test 4: Invalid request - both parameters provided"
echo "URL: $BASE_URL/current?latitude=52.5200&longitude=13.4050&city=Berlin"
curl -s "$BASE_URL/current?latitude=52.5200&longitude=13.4050&city=Berlin" | jq '.' || echo "Expected error response"
# Test 5: Invalid coordinates
echo
echo "❌ Test 5: Invalid coordinates"
echo "URL: $BASE_URL/current?latitude=100&longitude=200"
curl -s "$BASE_URL/current?latitude=100&longitude=200" | jq '.' || echo "Expected error response"
# Test 6: Non-existent city
echo
echo "❌ Test 6: Non-existent city"
echo "URL: $BASE_URL/current?city=NonExistentCityName123"
curl -s "$BASE_URL/current?city=NonExistentCityName123" | jq '.' || echo "Expected error response"
echo
echo "✅ Test script completed!"
echo "💡 Note: Make sure the application is running on port 8080"