diff mrjunejune/test/snapshots/README.md @ 67:6626ec933933

[Seobeo] Separated out Client Server logic. Created test tools.
author June Park <parkjune1995@gmail.com>
date Wed, 24 Dec 2025 09:15:55 -0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mrjunejune/test/snapshots/README.md	Wed Dec 24 09:15:55 2025 -0800
@@ -0,0 +1,76 @@
+# 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.