-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (105 loc) · 3.11 KB
/
test.yml
File metadata and controls
124 lines (105 loc) · 3.11 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
name: Test
on:
push:
branches: [main]
pull_request:
jobs:
install-only:
name: Install only (${{ matrix.os }})
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup mockd (install only)
uses: ./
id: mockd
- name: Verify installation
run: |
mockd version
echo "Installed version: ${{ steps.mockd.outputs.version }}"
test -n "${{ steps.mockd.outputs.version }}"
install-and-start:
name: Install + start (${{ matrix.os }})
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup mockd (with server)
uses: ./
id: mockd
with:
start: true
- name: Verify server is running
run: |
curl -sf "${{ steps.mockd.outputs.admin-url }}/health"
echo "Server healthy at ${{ steps.mockd.outputs.mockd-url }}"
- name: Create and test a mock
run: |
# Create a mock via admin API
curl -sf -X POST "${{ steps.mockd.outputs.admin-url }}/mocks" \
-H 'Content-Type: application/json' \
-d '{"name":"Test","type":"http","http":{"matcher":{"method":"GET","path":"/hello"},"response":{"statusCode":200,"body":"{\"msg\":\"world\"}"}}}'
# Hit the mock
RESPONSE=$(curl -sf "${{ steps.mockd.outputs.mockd-url }}/hello")
echo "Response: $RESPONSE"
echo "$RESPONSE" | grep -q "world"
pinned-version:
name: Pinned version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup mockd v0.4.4
uses: ./
id: mockd
with:
version: '0.4.4'
- name: Verify version
run: |
mockd version | grep -q "0.4.4"
with-config:
name: With config file
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create test config
run: |
cat > /tmp/test-mocks.yaml << 'EOF'
version: "1.0"
mocks:
- name: "Health"
type: http
http:
matcher:
method: GET
path: /api/health
response:
statusCode: 200
body: '{"status": "ok"}'
EOF
- name: Setup mockd with config
uses: ./
id: mockd
with:
start: true
config: /tmp/test-mocks.yaml
- name: Verify config loaded
run: |
# Wait a moment for config to load
sleep 2
curl -sf "${{ steps.mockd.outputs.mockd-url }}/api/health" | grep -q "ok"
cache-test:
name: Cache hit test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: First install (cache miss)
uses: ./
id: first
- name: Check cache status
run: |
echo "Cache hit: ${{ steps.first.outputs.cache-hit }}"
echo "Version: ${{ steps.first.outputs.version }}"