Ab#78611 #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Mock Tests | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| paths: | |
| - 'cmd/pamTypes_mock_test.go' | |
| - 'cmd/storeTypes_mock_test.go' | |
| - 'cmd/pamTypes.go' | |
| - 'cmd/storeTypes.go' | |
| - 'cmd/pam_types.json' | |
| - 'cmd/store_types.json' | |
| - '.github/workflows/mock_tests.yml' | |
| pull_request: | |
| paths: | |
| - 'cmd/pamTypes_mock_test.go' | |
| - 'cmd/storeTypes_mock_test.go' | |
| - 'cmd/pamTypes.go' | |
| - 'cmd/storeTypes.go' | |
| - 'cmd/pam_types.json' | |
| - 'cmd/store_types.json' | |
| - '.github/workflows/mock_tests.yml' | |
| workflow_dispatch: | |
| jobs: | |
| pam-types-mock-tests: | |
| name: PAM Types Mock Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24' | |
| cache: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run PAM Types Mock Tests | |
| run: | | |
| echo "::group::Running PAM Types Mock Tests" | |
| go test -v ./cmd -run "Test_PAMTypes_Mock" -timeout 2m | |
| echo "::endgroup::" | |
| - name: Generate PAM Types Test Summary | |
| if: always() | |
| run: | | |
| echo "## PAM Types Mock Tests Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| go test ./cmd -run "Test_PAMTypes_Mock" -v 2>&1 | grep -E "(PASS|FAIL|RUN)" | tee -a $GITHUB_STEP_SUMMARY || true | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ PAM Types Mock Tests Completed" >> $GITHUB_STEP_SUMMARY | |
| store-types-mock-tests: | |
| name: Store Types Mock Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24' | |
| cache: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run Store Types Mock Tests | |
| run: | | |
| echo "::group::Running Store Types Mock Tests" | |
| go test -v ./cmd -run "Test_StoreTypes_Mock" -timeout 2m | |
| echo "::endgroup::" | |
| - name: Generate Store Types Test Summary | |
| if: always() | |
| run: | | |
| echo "## Store Types Mock Tests Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| go test ./cmd -run "Test_StoreTypes_Mock" -v 2>&1 | grep -E "(PASS|FAIL|RUN)" | tee -a $GITHUB_STEP_SUMMARY || true | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ Store Types Mock Tests Completed" >> $GITHUB_STEP_SUMMARY | |
| mock-tests-summary: | |
| name: Mock Tests Summary | |
| runs-on: ubuntu-latest | |
| needs: [ pam-types-mock-tests, store-types-mock-tests ] | |
| if: always() | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24' | |
| cache: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run All Mock Test Summaries | |
| run: | | |
| echo "::group::PAM Types Summary" | |
| go test -v ./cmd -run "Test_PAMTypes_Mock_Summary" -timeout 1m | |
| echo "::endgroup::" | |
| echo "" | |
| echo "::group::Store Types Summary" | |
| go test -v ./cmd -run "Test_StoreTypes_Mock_Summary" -timeout 1m | |
| echo "::endgroup::" | |
| - name: Generate Combined Summary | |
| if: always() | |
| run: | | |
| # Calculate statistics from JSON files and test output | |
| PAM_TYPES_TOTAL=$(jq '. | length' cmd/pam_types.json) | |
| STORE_TYPES_TOTAL=$(jq '. | length' cmd/store_types.json) | |
| # Count test cases from test files | |
| PAM_MOCK_CREATE_TESTS=$(grep -c "Test_PAMTypes_Mock_CreateAllTypes" cmd/pamTypes_mock_test.go || echo "0") | |
| STORE_MOCK_CREATE_TESTS=$(grep -c "Test_StoreTypes_Mock_CreateAllTypes" cmd/storeTypes_mock_test.go || echo "0") | |
| # Run tests with JSON output to count operations | |
| PAM_TEST_OUTPUT=$(go test -json ./cmd -run "Test_PAMTypes_Mock" 2>&1 || echo "") | |
| STORE_TEST_OUTPUT=$(go test -json ./cmd -run "Test_StoreTypes_Mock" 2>&1 || echo "") | |
| # Count passed subtests for PAM types | |
| 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 ' ') | |
| # Count passed subtests for Store types | |
| 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 ' ') | |
| # Calculate tested counts (first 10 for store types based on test implementation) | |
| PAM_TESTED=$PAM_TYPES_TOTAL | |
| STORE_TESTED=$STORE_TYPES_TOTAL | |
| # Calculate percentages | |
| PAM_PERCENT=$((100 * PAM_TESTED / PAM_TYPES_TOTAL)) | |
| STORE_PERCENT=$((100 * STORE_TESTED / STORE_TYPES_TOTAL)) | |
| # Count total operations (approximate: subtests - summary tests) | |
| TOTAL_OPS=$((PAM_SUBTESTS + STORE_SUBTESTS - 2)) | |
| # Generate summary | |
| echo "# 🎉 Mock Tests Complete Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "## Test Execution Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ needs.pam-types-mock-tests.result }}" == "success" ]; then | |
| echo "✅ **PAM Types Mock Tests**: PASSED" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "❌ **PAM Types Mock Tests**: FAILED" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| if [ "${{ needs.store-types-mock-tests.result }}" == "success" ]; then | |
| echo "✅ **Store Types Mock Tests**: PASSED" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "❌ **Store Types Mock Tests**: FAILED" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "## Coverage Statistics" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- **PAM Types Available**: ${PAM_TYPES_TOTAL}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **PAM Types Tested**: ${PAM_TESTED}/${PAM_TYPES_TOTAL} (${PAM_PERCENT}%)" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Store Types Available**: ${STORE_TYPES_TOTAL}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Store Types Tested**: ${STORE_TESTED}/${STORE_TYPES_TOTAL} (${STORE_PERCENT}%)" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Total Test Cases Passed**: ${TOTAL_OPS}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "## Test Files" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`cmd/pamTypes_mock_test.go\` - PAM Types HTTP Mock Tests (${PAM_SUBTESTS} subtests)" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`cmd/storeTypes_mock_test.go\` - Store Types HTTP Mock Tests (${STORE_SUBTESTS} subtests)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "## JSON Data Files" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`cmd/pam_types.json\` - ${PAM_TYPES_TOTAL} PAM provider types" >> $GITHUB_STEP_SUMMARY | |
| echo "- \`cmd/store_types.json\` - ${STORE_TYPES_TOTAL} certificate store types" >> $GITHUB_STEP_SUMMARY | |
| - name: Check Overall Status | |
| if: needs.pam-types-mock-tests.result != 'success' || needs.store-types-mock-tests.result != 'success' | |
| run: | | |
| echo "::error::One or more mock test jobs failed" | |
| exit 1 |