

4·
29 days agoI would love to learn to not worry, stress and ruminate about every little thing ever
I would love to learn to not worry, stress and ruminate about every little thing ever
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)
}
Ah yes a quote about beginners rapidly gaining beginner gains by practicing really does apply to a group of professionals trying to do their job in a business /s
It’s shocking the amount of morons people trying to do their job have to deal with nowadays. I’m sorry you have a colleague with the critical thinking ability of a punch drunk.