Skip to content

Commit 880d422

Browse files
committed
chore(ci/mock_tests): Dynamic summary for mock tests
Signed-off-by: spbsoluble <1661003+spbsoluble@users.noreply.github.com>
1 parent 5671c97 commit 880d422

1 file changed

Lines changed: 44 additions & 6 deletions

File tree

.github/workflows/mock_tests.yml

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Mock Tests
22

33
on:
44
push:
5+
branches: [ main, develop ]
56
paths:
67
- 'cmd/pamTypes_mock_test.go'
78
- 'cmd/storeTypes_mock_test.go'
@@ -11,6 +12,7 @@ on:
1112
- 'cmd/store_types.json'
1213
- '.github/workflows/mock_tests.yml'
1314
pull_request:
15+
branches: [ main, develop ]
1416
paths:
1517
- 'cmd/pamTypes_mock_test.go'
1618
- 'cmd/storeTypes_mock_test.go'
@@ -118,6 +120,36 @@ jobs:
118120
- name: Generate Combined Summary
119121
if: always()
120122
run: |
123+
# Calculate statistics from JSON files and test output
124+
PAM_TYPES_TOTAL=$(jq '. | length' cmd/pam_types.json)
125+
STORE_TYPES_TOTAL=$(jq '. | length' cmd/store_types.json)
126+
127+
# Count test cases from test files
128+
PAM_MOCK_CREATE_TESTS=$(grep -c "Test_PAMTypes_Mock_CreateAllTypes" cmd/pamTypes_mock_test.go || echo "0")
129+
STORE_MOCK_CREATE_TESTS=$(grep -c "Test_StoreTypes_Mock_CreateAllTypes" cmd/storeTypes_mock_test.go || echo "0")
130+
131+
# Run tests with JSON output to count operations
132+
PAM_TEST_OUTPUT=$(go test -json ./cmd -run "Test_PAMTypes_Mock" 2>&1 || echo "")
133+
STORE_TEST_OUTPUT=$(go test -json ./cmd -run "Test_StoreTypes_Mock" 2>&1 || echo "")
134+
135+
# Count passed subtests for PAM types
136+
PAM_SUBTESTS=$(echo "$PAM_TEST_OUTPUT" | jq -r 'select(.Action == "pass" and .Test != null and (.Test | contains("Mock"))) | .Test' 2>/dev/null | wc -l | tr -d ' ')
137+
138+
# Count passed subtests for Store types
139+
STORE_SUBTESTS=$(echo "$STORE_TEST_OUTPUT" | jq -r 'select(.Action == "pass" and .Test != null and (.Test | contains("Mock"))) | .Test' 2>/dev/null | wc -l | tr -d ' ')
140+
141+
# Calculate tested counts (first 10 for store types based on test implementation)
142+
PAM_TESTED=$PAM_TYPES_TOTAL
143+
STORE_TESTED=10
144+
145+
# Calculate percentages
146+
PAM_PERCENT=$((100 * PAM_TESTED / PAM_TYPES_TOTAL))
147+
STORE_PERCENT=$((100 * STORE_TESTED / STORE_TYPES_TOTAL))
148+
149+
# Count total operations (approximate: subtests - summary tests)
150+
TOTAL_OPS=$((PAM_SUBTESTS + STORE_SUBTESTS - 2))
151+
152+
# Generate summary
121153
echo "# 🎉 Mock Tests Complete Summary" >> $GITHUB_STEP_SUMMARY
122154
echo "" >> $GITHUB_STEP_SUMMARY
123155
echo "## Test Execution Results" >> $GITHUB_STEP_SUMMARY
@@ -138,15 +170,21 @@ jobs:
138170
echo "" >> $GITHUB_STEP_SUMMARY
139171
echo "## Coverage Statistics" >> $GITHUB_STEP_SUMMARY
140172
echo "" >> $GITHUB_STEP_SUMMARY
141-
echo "- **PAM Types Tested**: 9/9 (100%)" >> $GITHUB_STEP_SUMMARY
142-
echo "- **Store Types Tested**: 10-15/62 (~20%)" >> $GITHUB_STEP_SUMMARY
143-
echo "- **Total HTTP Operations**: 90+ validated" >> $GITHUB_STEP_SUMMARY
144-
echo "- **Execution Time**: < 40ms" >> $GITHUB_STEP_SUMMARY
173+
echo "- **PAM Types Available**: ${PAM_TYPES_TOTAL}" >> $GITHUB_STEP_SUMMARY
174+
echo "- **PAM Types Tested**: ${PAM_TESTED}/${PAM_TYPES_TOTAL} (${PAM_PERCENT}%)" >> $GITHUB_STEP_SUMMARY
175+
echo "- **Store Types Available**: ${STORE_TYPES_TOTAL}" >> $GITHUB_STEP_SUMMARY
176+
echo "- **Store Types Tested**: ${STORE_TESTED}/${STORE_TYPES_TOTAL} (${STORE_PERCENT}%)" >> $GITHUB_STEP_SUMMARY
177+
echo "- **Total Test Cases Passed**: ${TOTAL_OPS}" >> $GITHUB_STEP_SUMMARY
145178
echo "" >> $GITHUB_STEP_SUMMARY
146179
echo "## Test Files" >> $GITHUB_STEP_SUMMARY
147180
echo "" >> $GITHUB_STEP_SUMMARY
148-
echo "- \`cmd/pamTypes_mock_test.go\` - PAM Types HTTP Mock Tests" >> $GITHUB_STEP_SUMMARY
149-
echo "- \`cmd/storeTypes_mock_test.go\` - Store Types HTTP Mock Tests" >> $GITHUB_STEP_SUMMARY
181+
echo "- \`cmd/pamTypes_mock_test.go\` - PAM Types HTTP Mock Tests (${PAM_SUBTESTS} subtests)" >> $GITHUB_STEP_SUMMARY
182+
echo "- \`cmd/storeTypes_mock_test.go\` - Store Types HTTP Mock Tests (${STORE_SUBTESTS} subtests)" >> $GITHUB_STEP_SUMMARY
183+
echo "" >> $GITHUB_STEP_SUMMARY
184+
echo "## JSON Data Files" >> $GITHUB_STEP_SUMMARY
185+
echo "" >> $GITHUB_STEP_SUMMARY
186+
echo "- \`cmd/pam_types.json\` - ${PAM_TYPES_TOTAL} PAM provider types" >> $GITHUB_STEP_SUMMARY
187+
echo "- \`cmd/store_types.json\` - ${STORE_TYPES_TOTAL} certificate store types" >> $GITHUB_STEP_SUMMARY
150188
151189
- name: Check Overall Status
152190
if: needs.pam-types-mock-tests.result != 'success' || needs.store-types-mock-tests.result != 'success'

0 commit comments

Comments
 (0)