Skip to content

Commit a564274

Browse files
cubapthehabes
andauthored
Describing test cases from changes without adding tests (#109)
* Add planned route test case specs Add harness-agnostic test case specifications for route behavior under error conditions. Five new markdown files were added under routes/__tests__: create-route, delete-route, update-route, overwrite-route, and error-messenger. Each file documents missing coverage such as upstream non-2xx passthroughs (JSON/text), network/timeouts mapping to 502, content-type and validation edge cases, header/body precedence, empty-body behavior, and parity checks with legacy /app endpoints. * Update cd_dev.yaml * changes while reviewing --------- Co-authored-by: Bryan Haberberger <bryan.j.haberberger@slu.edu>
1 parent c9082e6 commit a564274

5 files changed

Lines changed: 145 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Create Route Test Cases
2+
3+
These are planned coverage cases only. They are intentionally harness-agnostic.
4+
5+
## Scope
6+
7+
Target: `POST /create` and `POST /app/create`
8+
9+
## Missing Coverage
10+
11+
1. Upstream JSON error passthrough
12+
- Setup: upstream returns non-2xx with `Content-Type: application/json` body
13+
- Expected: TinyNode returns same status; body forwarded as plain text through shared messenger
14+
15+
2. Missing `Content-Type` header on request
16+
- Setup: client sends valid JSON body but omits `Content-Type`
17+
- Expected: `415 Unsupported Media Type`
18+
19+
3. Multiple `Content-Type` values
20+
- Setup: request header includes multiple comma-separated MIME values
21+
- Expected: `415 Unsupported Media Type`
22+
23+
4. Upstream timeout/network failure classification
24+
- Setup: fetch rejects with timeout/socket error
25+
- Expected: `502 Bad Gateway` with deterministic plain-text error message
26+
27+
5. Legacy route parity
28+
- Setup: run the same failing scenarios against `/app/create`
29+
- Expected: status and body parity with `/create`
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Delete Route Test Cases
2+
3+
These are planned coverage cases only. They are intentionally harness-agnostic.
4+
5+
## Scope
6+
7+
Target: `DELETE /delete`, `DELETE /delete/:id`, and legacy `/app` equivalents
8+
9+
## Missing Coverage
10+
11+
1. Body-delete upstream failure passthrough
12+
- Setup: `/delete` upstream returns non-2xx
13+
- Expected: error goes through shared messenger with preserved status
14+
15+
2. Path-delete upstream failure passthrough
16+
- Setup: `/delete/:id` upstream returns non-2xx
17+
- Expected: error goes through shared messenger with preserved status
18+
19+
3. Network failure mapping for both delete forms
20+
- Setup: fetch rejects for `/delete` and `/delete/:id`
21+
- Expected: `502 Bad Gateway`
22+
23+
4. Missing id/body validation behavior
24+
- Setup: `/delete` without id in body
25+
- Expected: `400` with clear message
26+
27+
5. Legacy route parity
28+
- Setup: mirror failure scenarios for `/app/delete` and `/app/delete/:id`
29+
- Expected: same behavior as non-legacy routes
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Shared Error Messenger Test Cases
2+
3+
These are planned coverage cases only. They are intentionally harness-agnostic.
4+
5+
## Scope
6+
7+
Target: shared middleware in `error-messenger.js`
8+
9+
## Missing Coverage
10+
11+
1. Generic Error fallback
12+
- Setup: plain `Error` object without response-like fields
13+
- Expected: `500` fallback with safe plain-text message
14+
15+
2. Headers already sent guard
16+
- Setup: middleware invoked after headers were sent
17+
- Expected: middleware exits without secondary write attempts
18+
19+
3. `.text()` failure fallback
20+
- Setup: upstream response `.text()` rejects (e.g., body stream already consumed)
21+
- Expected: middleware uses generic fallback message with status preserved
22+
23+
4. Empty upstream body behavior
24+
- Setup: upstream error response has status but empty body
25+
- Expected: status preserved and default message used
26+
27+
5. Status source precedence
28+
- Setup: error object has multiple status fields (`statusCode`, `status`)
29+
- Expected: precedence is deterministic and documented
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Overwrite Route Test Cases
2+
3+
These are planned coverage cases only. They are intentionally harness-agnostic.
4+
5+
## Scope
6+
7+
Target: `PUT /overwrite` and `PUT /app/overwrite`
8+
9+
## Missing Coverage
10+
11+
1. Conflict (`409`) passthrough
12+
- Setup: upstream returns `409` with JSON current version payload
13+
- Expected: TinyNode returns `409` and same JSON payload
14+
15+
2. Header precedence contract
16+
- Setup: both `If-Overwritten-Version` header and `__rerum.isOverwritten` body value are supplied
17+
- Expected: documented precedence is consistently enforced
18+
19+
3. Non-JSON upstream error response
20+
- Setup: upstream returns non-2xx with missing or non-JSON content type
21+
- Expected: shared messenger handles without local exception
22+
23+
4. Network failure mapping
24+
- Setup: fetch rejects before upstream response
25+
- Expected: `502 Bad Gateway`
26+
27+
5. Legacy route parity
28+
- Setup: same conflict/error scenarios against `/app/overwrite`
29+
- Expected: parity with `/overwrite`
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Update Route Test Cases
2+
3+
These are planned coverage cases only. They are intentionally harness-agnostic.
4+
5+
## Scope
6+
7+
Target: `PUT /update` and `PUT /app/update`
8+
9+
## Missing Coverage
10+
11+
1. Upstream non-2xx text error passthrough
12+
- Setup: upstream update returns text/plain error and non-2xx status
13+
- Expected: TinyNode returns same status and text
14+
15+
2. Upstream JSON error passthrough
16+
- Setup: upstream update returns JSON error payload and non-2xx status
17+
- Expected: TinyNode returns same status and JSON body
18+
19+
3. Network failure mapping
20+
- Setup: fetch rejects before upstream response
21+
- Expected: `502 Bad Gateway`
22+
23+
4. Identifier edge cases
24+
- Setup: body contains malformed `@id` value (type mismatch, blank string)
25+
- Expected: explicit `400` validation response
26+
27+
5. Response shape consistency
28+
- Setup: successful update returns object
29+
- Expected: `200`, `Location` header populated, JSON response body

0 commit comments

Comments
 (0)