When we introduced our sample service, we identified several issues related to testing. The first of these issues was the lack of isolation, where tests for one layer were also indirectly testing all the layers below it, as shown in the following code:
func TestGetHandler_ServeHTTP(t *testing.T) { // ensure the test always fails by giving it a timeout ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() // Create and start a server // With out current implementation, we cannot test this handler without // a full server as we need the mux. address, err := startServer(ctx) require.NoError(t, err) // build inputs response, err := http.Get("http://" + address + "/person/1/" ...