Skip to content

Commit 26f445f

Browse files
committed
feat: add support for epcc get-all <resource> (Resolves #632)
1 parent 5536398 commit 26f445f

File tree

15 files changed

+1243
-4
lines changed

15 files changed

+1243
-4
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ jobs:
5555
run: |
5656
go test -v -cover ./cmd/ ./external/...
5757
58+
- name: Get-All Smoke Test
59+
timeout-minutes: 10
60+
env:
61+
EPCC_CLIENT_ID: ${{ secrets.EPCC_CLIENT_ID }}
62+
EPCC_CLIENT_SECRET: ${{ secrets.EPCC_CLIENT_SECRET }}
63+
EPCC_API_BASE_URL: ${{ vars.EPCC_API_BASE_URL }}
64+
run: |
65+
export PATH=./bin/:$PATH
66+
./cmd/get-all-smoke-tests.sh
67+
5868
- name: Runbook Smoke Test
5969
timeout-minutes: 15
6070
env:

cmd/get-all-smoke-tests.sh

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/bin/env bash
2+
3+
# Round-trip smoke test for the get-all command
4+
# 1. Create resources from different families
5+
# 2. Export them with a single get-all --output-format epcc-cli
6+
# 3. Delete the resources
7+
# 4. Run the exported script to recreate them
8+
# 5. Verify resources were recreated
9+
10+
set -e
11+
12+
TEMP_DIR=$(mktemp -d)
13+
14+
cleanup() {
15+
rm -rf "$TEMP_DIR"
16+
}
17+
trap cleanup EXIT
18+
19+
echo "=== get-all Round-Trip Smoke Test ==="
20+
epcc reset-store .+
21+
22+
# Step 1: Create resources from different families
23+
echo "=== Step 1: Creating test resources ==="
24+
25+
# Account and sub-resource (account-address)
26+
epcc create account name "get-all-test-account" legal_name "Test Account for get-all"
27+
epcc create account-address account/name=get-all-test-account name "Test Address" first_name "John" last_name "Doe" line_1 "123 Test St" city "Test City" postcode "H0H 0H0" county "Test County" country "US"
28+
29+
# Customer
30+
epcc create customer name "get-all-test-customer" email "get-all-test@example.com"
31+
32+
33+
# Custom API with fields and entry
34+
epcc create custom-api name "smoke-test-api" slug "smoke-test-api" api_type "smoke_test_ext" description "Smoke test API"
35+
epcc create custom-field custom_api/slug=smoke-test-api name "test_string" description blah slug "test_string" field_type "string"
36+
epcc create custom-field custom_api/slug=smoke-test-api name "test_int" description blah slug "test_int" field_type "integer"
37+
epcc create custom-field custom_api/slug=smoke-test-api name "test_bool" description blah slug "test_bool" field_type "boolean"
38+
epcc create custom-api-settings-entry custom_api/slug=smoke-test-api data.test_string "hello world" data.test_int 42 data.test_bool true data.type "smoke_test_ext"
39+
40+
echo "=== Step 2: Export all resources with single get-all ==="
41+
42+
epcc get-all accounts account-addresses customers custom-apis custom-fields custom-api-settings-entries \
43+
--output-file "$TEMP_DIR/export.sh" --output-format epcc-cli --truncate-output
44+
45+
echo "=== Step 3: Delete resources ==="
46+
47+
# Delete in reverse dependency order
48+
epcc delete-all custom-api-settings-entries
49+
epcc delete-all custom-fields
50+
epcc delete-all custom-apis
51+
epcc delete-all customers
52+
epcc delete-all account-addresses
53+
epcc delete-all accounts
54+
55+
echo "=== Step 4: Run exported script to recreate resources ==="
56+
57+
"$TEMP_DIR/export.sh"
58+
59+
echo "=== Step 5: Verify resources were recreated ==="
60+
61+
# Check account exists
62+
ACCOUNT_COUNT=$(epcc get accounts --output-jq '.meta.results.total')
63+
if [ "$ACCOUNT_COUNT" -lt 1 ]; then
64+
echo "FAIL: No accounts found after recreation"
65+
exit 1
66+
fi
67+
echo "PASS: Accounts recreated ($ACCOUNT_COUNT found)"
68+
69+
# Check account-address exists
70+
ADDRESS_COUNT=$(epcc get account-addresses account/name=get-all-test-account --output-jq '.meta.results.total' 2>/dev/null || echo "0")
71+
if [ "$ADDRESS_COUNT" -lt 1 ]; then
72+
echo "FAIL: No account-addresses found after recreation"
73+
exit 1
74+
fi
75+
echo "PASS: Account-addresses recreated ($ADDRESS_COUNT found)"
76+
77+
# Check customer exists
78+
CUSTOMER_COUNT=$(epcc get customers --output-jq '.meta.results.total')
79+
if [ "$CUSTOMER_COUNT" -lt 1 ]; then
80+
echo "FAIL: No customers found after recreation"
81+
exit 1
82+
fi
83+
echo "PASS: Customers recreated ($CUSTOMER_COUNT found)"
84+
85+
# Check custom-api exists
86+
CUSTOM_API_EXISTS=$(epcc get custom-api slug=smoke-test-api --output-jq '.data.slug' 2>/dev/null || echo "")
87+
if [ "$CUSTOM_API_EXISTS" != "smoke-test-api" ]; then
88+
echo "FAIL: Custom API smoke-test-api not found after recreation"
89+
exit 1
90+
fi
91+
echo "PASS: Custom API recreated"
92+
93+
# Check custom-fields exist
94+
FIELD_COUNT=$(epcc get custom-fields custom_api/slug=smoke-test-api --output-jq '.meta.results.total' 2>/dev/null || echo "0")
95+
if [ "$FIELD_COUNT" -lt 3 ]; then
96+
echo "FAIL: Expected at least 3 custom-fields, found $FIELD_COUNT"
97+
exit 1
98+
fi
99+
echo "PASS: Custom fields recreated ($FIELD_COUNT found)"
100+
101+
# Check custom-api-settings-entry exists
102+
ENTRY_COUNT=$(epcc get custom-api-settings-entries custom_api/slug=smoke-test-api --output-jq '.meta.results.total' 2>/dev/null || echo "0")
103+
if [ "$ENTRY_COUNT" -lt 1 ]; then
104+
echo "FAIL: No custom-api-settings-entries found after recreation"
105+
exit 1
106+
fi
107+
echo "PASS: Custom API entries recreated ($ENTRY_COUNT found)"
108+
109+
echo ""
110+
echo "=== get-all Round-Trip Smoke Test PASSED ==="

0 commit comments

Comments
 (0)