Commit ab572ec
authored
test: fail fast on missing VCR cassettes by converting errors to 404 (#2816)
If a VCR cassette or a specific interaction is missing, the OSV client
would previously retry the request 4 times with exponential backoff,
causing significant delays in test execution (over 20 seconds).
This change wraps the VCR client transport in tests to intercept the
"requested interaction not found" error (using `errors.Is` with
`cassette.ErrInteractionNotFound` for robust matching) and convert it to
a "404 Not Found" response. Since the OSV client does not retry on 404
status codes, this allows tests to fail immediately (~0.02s) when a
cassette or interaction is missing while still preserving retry behavior
for genuine transient network errors.
This approach avoids modifying the core `osvscanner` library API or
adding new CLI flags.
- Implemented `vcrErrorWrappingTransport` in `internal/testcmd/vcr.go`
- Wrapped the VCR client transport in `InsertCassette`
- Used `errors.Is` with `cassette.ErrInteractionNotFound` for robust
error matching1 parent 57b8b78 commit ab572ec
1 file changed
Lines changed: 25 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
176 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
177 | 181 | | |
178 | 182 | | |
179 | 183 | | |
| |||
255 | 259 | | |
256 | 260 | | |
257 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
0 commit comments