If it was me personally I would just test the handlers separately rather than scaffolding the router entirely.
Either way, I suggest looking into using the standard lib http/httptest
https://pkg.go.dev/net/http/httptest
Here's an snippet example of testing a handler
req, err := http.NewRequest(http.MethodGet, "/health", bytes.NewBuffer([]byte{}))
if err != nil {
t.Fatal(err)
}
rr := httptest.NewRecorder()
handler := http.HandlerFunc(srv.HealthCheckHandler)
handler.ServeHTTP(rr, req)
if rr.Code != http.StatusOK {
t.Fatalf("expect HTTP response code %d, got %d", tt.expectHttpCode, rr.Code)
}
I would love to learn to not worry, stress and ruminate about every little thing ever