MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / testServer

Function testServer

internal/server/server_test.go:19–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func 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
40func doRequest(srv *Server, method, path string, body interface{}) *httptest.ResponseRecorder {
41 return doRequestFromRemoteAddr(srv, method, path, body, "192.0.2.1:1234")

Calls 3

NewSQLiteFunction · 0.92
NewFunction · 0.70
StopMethod · 0.45

Tested by

no test coverage detected