Mercurial
comparison mrjunejune/test/README.md @ 94:092afa595764
[MrJuneJune] Added Integration tests.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Fri, 02 Jan 2026 18:13:32 -0800 |
| parents | |
| children | 1c446ab6f945 |
comparison
equal
deleted
inserted
replaced
| 93:be91a73d801a | 94:092afa595764 |
|---|---|
| 1 # MrJuneJune Integration Tests | |
| 2 | |
| 3 This directory contains comprehensive integration tests for all mrjunejune endpoints. | |
| 4 | |
| 5 ## Test Structure | |
| 6 | |
| 7 ### Test Files | |
| 8 - `integration_test.c` - Main integration test suite | |
| 9 - `create_snapshots.c` - Utility to generate/update snapshot files | |
| 10 - `shiba.webp` - Test image for image-to-webp conversion | |
| 11 - `test_avi.avi` - Test video for video-to-mp4 conversion | |
| 12 | |
| 13 ### Snapshot Directory | |
| 14 - `snapshots/` - Contains expected HTTP responses for GET endpoints | |
| 15 | |
| 16 ## Endpoints Tested | |
| 17 | |
| 18 ### GET Endpoints (200 OK with Snapshot Verification) | |
| 19 - `/` - Home page | |
| 20 - `/resume` - Resume page | |
| 21 - `/tools` - Tools page | |
| 22 - `/tools/markdown_to_html` - Markdown to HTML converter | |
| 23 - `/tools/file_converter` - File converter tool | |
| 24 | |
| 25 ### GET Endpoints (301 Redirects) | |
| 26 - `/index.html` → `/` | |
| 27 - `/resume/index.html` → `/resume` | |
| 28 - `/tools/index.html` → `/tools` | |
| 29 - `/tools/markdown_to_html/index.html` → `/tools/markdown_to_html` | |
| 30 - `/tools/file_converter/index.html` → `/tools/file_converter` | |
| 31 | |
| 32 ### GET Endpoints (404 Not Found) | |
| 33 - `/nonexistent` | |
| 34 - `/does/not/exist` | |
| 35 - `/missing.html` | |
| 36 | |
| 37 ### POST Endpoints | |
| 38 - `/api/convert/image-to-webp` - Converts images to WebP format | |
| 39 - Tests file upload, conversion, and download | |
| 40 - Verifies Content-Type: image/webp | |
| 41 - `/api/convert/video-to-mp4` - Converts videos to MP4 format | |
| 42 - Tests file upload, conversion, and download | |
| 43 - Verifies Content-Type: video/mp4 | |
| 44 | |
| 45 ### Download Endpoint | |
| 46 - `/api/download/:filename` - Download converted files | |
| 47 - Tested automatically as part of POST conversion tests | |
| 48 | |
| 49 ## Running Tests | |
| 50 | |
| 51 ### First Time Setup - Create Snapshots | |
| 52 Before running tests for the first time, generate snapshots: | |
| 53 | |
| 54 ```bash | |
| 55 bazel run //mrjunejune:create_snapshots | |
| 56 ``` | |
| 57 | |
| 58 This will: | |
| 59 1. Start the mrjunejune server | |
| 60 2. Make HTTP requests to all GET endpoints | |
| 61 3. Save responses to `snapshots/` directory | |
| 62 4. Stop the server | |
| 63 | |
| 64 ### Run Integration Tests | |
| 65 ```bash | |
| 66 bazel test //mrjunejune:integration_test | |
| 67 ``` | |
| 68 | |
| 69 This will: | |
| 70 1. Start the mrjunejune server on port 6969 | |
| 71 2. Test all GET endpoints against their snapshots | |
| 72 3. Test POST conversion endpoints with real file uploads | |
| 73 4. Verify downloads work correctly | |
| 74 5. Report pass/fail for each test | |
| 75 | |
| 76 ### View Test Output | |
| 77 ```bash | |
| 78 bazel test //mrjunejune:integration_test --test_output=all | |
| 79 ``` | |
| 80 | |
| 81 ## Test Coverage | |
| 82 | |
| 83 ✓ All 10 registered endpoints are tested | |
| 84 ✓ Snapshot testing for HTML responses | |
| 85 ✓ File upload and conversion testing | |
| 86 ✓ Download functionality testing | |
| 87 ✓ Error handling (404 responses) | |
| 88 ✓ Redirect testing (301 responses) | |
| 89 | |
| 90 ## Updating Tests | |
| 91 | |
| 92 ### When HTML Changes | |
| 93 If you modify any HTML templates: | |
| 94 | |
| 95 ```bash | |
| 96 # Regenerate snapshots | |
| 97 bazel run //mrjunejune:create_snapshots | |
| 98 | |
| 99 # Run tests to verify | |
| 100 bazel test //mrjunejune:integration_test | |
| 101 ``` | |
| 102 | |
| 103 ### When Adding New Endpoints | |
| 104 1. Update `main.c` with new route | |
| 105 2. Add test case to `integration_test.c` | |
| 106 3. Add snapshot config to `create_snapshots.c` (for GET) | |
| 107 4. Regenerate snapshots | |
| 108 5. Run tests | |
| 109 | |
| 110 ## Notes | |
| 111 | |
| 112 - Tests require FFmpeg to be installed for video/image conversion tests | |
| 113 - Server runs on port 6969 during tests | |
| 114 - Test files are cleaned up automatically after download | |
| 115 - Converted files are stored in `/tmp/` during tests |