-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_api.sh
More file actions
executable file
·69 lines (58 loc) · 2 KB
/
test_api.sh
File metadata and controls
executable file
·69 lines (58 loc) · 2 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
#!/bin/bash
# Simple API test script for PrivateLedger
BASE_URL="http://localhost:8844"
echo "======================================"
echo "PrivateLedger API Test Script"
echo "======================================"
echo ""
# Test 1: Root endpoint
echo "1. Testing root endpoint..."
curl -s "${BASE_URL}/" | jq '.'
echo ""
# Test 2: Create an account
echo "2. Creating a test account..."
ACCOUNT_RESPONSE=$(curl -s -X POST "${BASE_URL}/api/accounts" \
-H "Content-Type: application/json" \
-d '{"name":"Test Account"}')
echo "$ACCOUNT_RESPONSE" | jq '.'
ACCOUNT_ID=$(echo "$ACCOUNT_RESPONSE" | jq -r '.account_id')
echo "Created account ID: $ACCOUNT_ID"
echo ""
# Test 3: List accounts
echo "3. Listing all accounts..."
curl -s "${BASE_URL}/api/accounts" | jq '.'
echo ""
# Test 4: Create a category
echo "4. Creating a test category with patterns..."
CATEGORY_RESPONSE=$(curl -s -X POST "${BASE_URL}/api/categories" \
-H "Content-Type: application/json" \
-d '{"name":"Groceries","color":"#4CAF50","patterns":["WALMART","LOBLAWS","SOBEYS"]}')
echo "$CATEGORY_RESPONSE" | jq '.'
CATEGORY_ID=$(echo "$CATEGORY_RESPONSE" | jq -r '.category_id')
echo "Created category ID: $CATEGORY_ID"
echo ""
# Test 5: List categories
echo "5. Listing all categories with patterns..."
curl -s "${BASE_URL}/api/categories" | jq '.'
echo ""
# Test 6: Get dashboard stats
echo "6. Getting dashboard stats..."
curl -s "${BASE_URL}/api/insights/dashboard" | jq '.'
echo ""
# Test 7: Get current period
echo "7. Getting current period..."
curl -s "${BASE_URL}/api/insights/current-period" | jq '.'
echo ""
# Test 8: List transactions (should be empty)
echo "8. Listing transactions (should be empty)..."
curl -s "${BASE_URL}/api/transactions" | jq '.'
echo ""
echo "======================================"
echo "Tests completed!"
echo "======================================"
echo ""
echo "To import OFX files, use:"
echo "curl -X POST ${BASE_URL}/api/import \\"
echo " -F \"[email protected]\" \\"
echo " -F \"account_id=${ACCOUNT_ID}\""
echo ""