Test Output
==========================================
Testing Grep Patterns for JSON Matching
==========================================
Test 1: Formatted JSON with spaces
-----------------------------------
Input: {"status": "healthy", "environment": "production"}
โ
PASS: Pattern matched formatted JSON
Test 2: Compact JSON without spaces
-----------------------------------
Input: {"status":"healthy","environment":"production"}
โ
PASS: Pattern matched compact JSON
Test 3: Pretty-printed multi-line JSON
---------------------------------------
Input: (multi-line JSON)
โ
PASS: Pattern matched pretty-printed JSON
Test 4: Should NOT match unhealthy
-----------------------------------
Input: {"status": "unhealthy", "environment": "production"}
โ
PASS: Correctly rejected unhealthy status
Test 5: Should NOT match degraded
-----------------------------------
Input: {"status": "degraded", "environment": "production"}
โ
PASS: Correctly rejected degraded status
Test 6: Environment matching
-----------------------------
Input: {"status": "healthy", "environment": "production"}
Expected environment: production
โ
PASS: Environment pattern matched
Test 7: Environment mismatch
-----------------------------
Input: {"status": "healthy", "environment": "production"}
Expected environment: development
โ
PASS: Correctly rejected environment mismatch
==========================================
โ
All tests passed!
==========================================
The grep patterns now correctly handle:
โข Compact JSON: {"status":"healthy"}
โข Formatted JSON: {"status": "healthy"}
โข Pretty-printed JSON (multi-line)
Pattern used: '"status"[[:space:]]*:[[:space:]]*"healthy"'
This pattern matches optional whitespace around the colon.
==========================================