Mercurial
view mrjunejune/test/snapshots/README.md @ 71:75de5903355c
Giagantic changes that update Dowa library to be more align with stb style array and hashmap. Updated Seobeo to be caching on server side instead of file level caching. Deleted bunch of things I don't really use.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Sun, 28 Dec 2025 20:34:22 -0800 |
| parents | 6626ec933933 |
| children |
line wrap: on
line source
# Test Snapshots This directory contains expected HTTP response snapshots for integration tests. ## How It Works Each test case generates a snapshot file based on its URL path: - `/` → `root.snapshot` - `/index.html` → `index.html.snapshot` - `/api/users` → `api_users.snapshot` - `/path/to/resource` → `path_to_resource.snapshot` ## Workflow ### First time (no snapshots exist): 1. Create snapshots: ```bash bazel run //mrjunejune:create_snapshots ``` This will: - Start the test server - Make HTTP requests to all test paths - Save responses to `mrjunejune/test/snapshots/` 2. Verify tests pass: ```bash bazel test //mrjunejune:integration_test ``` All tests should now pass since snapshots exist. ### Updating Snapshots When you change the server response format: 1. Regenerate snapshots: ```bash bazel run //mrjunejune:create_snapshots ``` 2. Verify tests still pass: ```bash bazel test //mrjunejune:integration_test ``` 3. Commit the updated snapshot files ## Two Separate Commands - **`bazel run //mrjunejune:create_snapshots`** - Creates/updates snapshot files (uses seobeo snapshot creator library) - **`bazel test //mrjunejune:integration_test`** - Verifies responses match snapshots This separation makes it clear when you're creating new snapshots vs. verifying against existing ones. ## Implementation Details The snapshot creation is implemented in the seobeo library: - `seobeo/snapshot_creator.h` - Snapshot creation API - `seobeo/snapshot_creator.c` - Implementation - `mrjunejune/test/create_snapshots.c` - Binary that uses the library This makes snapshot creation reusable across different projects. ## Special Cases ### 200 OK Responses Only 200 OK responses are verified against snapshots. This ensures successful responses remain consistent. ### Redirects (3xx status codes) Redirect responses skip content comparison - only the status code is verified. ### Error Responses (4xx, 5xx) Error status codes are verified but content comparison is skipped to allow for response format flexibility.