forgejo/models/unittest
forgejo-backport-action 68f39ad66b [v14.0/forgejo] fix NewMockWebServer(): Headers never reached the http client (#11058)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/11007

Found while working on https://codeberg.org/forgejo/forgejo/pulls/10798#issuecomment-10083846: The symptom was that the go-github client never returned a `resp.After`, so I tracked down the root cause, which was that, with the mocked http server ...

Mocked headers never reached the calling client, because w.WriteHeader()
was called before the headers were set in the response.

Fix by moving w.WriteHeader() to the right place just before w.Write(),
which writes the body.

Test added which fails without the fix and succeeds with it.

Co-authored-by: Nils Goroll <nils.goroll@uplex.de>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11058
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
2026-01-26 20:41:29 +01:00
..
testdata [v14.0/forgejo] fix NewMockWebServer(): Headers never reached the http client (#11058) 2026-01-26 20:41:29 +01:00
consistency.go fix: reduce deadlocks merging PRs by using caching for repo issue count stats (#9922) 2025-10-31 23:50:05 +01:00
fault_injector.go chore: add SQL fault injector testing (#9314) 2025-09-18 00:39:06 +02:00
fault_injector_test.go chore: add SQL fault injector testing (#9314) 2025-09-18 00:39:06 +02:00
fixture_loader.go feat: add foreign keys to stopwatch & tracked_time tables (#9373) 2025-10-01 00:31:38 +02:00
fixtures.go feat: add foreign keys to stopwatch & tracked_time tables (#9373) 2025-10-01 00:31:38 +02:00
fscopy.go chore: simplify CopyDir 2024-11-10 17:21:57 +01:00
mock_http.go [v14.0/forgejo] fix NewMockWebServer(): Headers never reached the http client (#11058) 2026-01-26 20:41:29 +01:00
mock_http_test.go [v14.0/forgejo] fix NewMockWebServer(): Headers never reached the http client (#11058) 2026-01-26 20:41:29 +01:00
reflection.go Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
testdb.go fix: reduce deadlocks merging PRs w/ async label stat recalcs (#9868) 2025-10-31 02:12:36 +01:00
unit_tests.go fix: reduce deadlocks merging PRs w/ async label stat recalcs (#9868) 2025-10-31 02:12:36 +01:00