(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func testServer(t *testing.T) *Server { |
| 20 | t.Helper() |
| 21 | // storetest.NewSQLite (IDEA-1914) runs the full migration chain at |
| 22 | // most once per test binary instead of once per call — see its |
| 23 | // package doc. It already registers its own t.Cleanup(s.Close); |
| 24 | // because testing.T runs cleanups LIFO, registering srv.Stop() here |
| 25 | // AFTER that call still runs Stop() BEFORE Close(), preserving the |
| 26 | // BUG-842 drain-then-close ordering below. |
| 27 | s := storetest.NewSQLite(t) |
| 28 | srv := New(s) |
| 29 | // Drain background goroutines BEFORE the store closes. Without this, |
| 30 | // fire-and-forget writes spawned by request middleware (e.g. |
| 31 | // TouchUserActivity in middleware_auth) can race the SQLite WAL/SHM |
| 32 | // file removal in t.TempDir's cleanup, causing |
| 33 | // "TempDir RemoveAll cleanup: directory not empty" — see BUG-842. |
| 34 | t.Cleanup(func() { |
| 35 | srv.Stop() |
| 36 | }) |
| 37 | return srv |
| 38 | } |
| 39 | |
| 40 | func doRequest(srv *Server, method, path string, body interface{}) *httptest.ResponseRecorder { |
| 41 | return doRequestFromRemoteAddr(srv, method, path, body, "192.0.2.1:1234") |
no test coverage detected