@@ -23,11 +23,9 @@ func TestReadServerVersion(t *testing.T) {
2323 hc := NewDefaultHealthCheck (nil , newHealthCheckConfigForTest (), lg )
2424 backend , info := newBackendServer (t )
2525 backend .setServerVersion ("1.0" )
26- //backend.serverVersion.Store("1.0")
2726 health := hc .Check (context .Background (), backend .sqlAddr , info )
2827 require .Equal (t , "1.0" , health .ServerVersion )
2928 backend .stopSQLServer ()
30- //backend.serverVersion.Store("2.0")
3129 backend .setServerVersion ("2.0" )
3230 backend .startSQLServer ()
3331 health = hc .Check (context .Background (), backend .sqlAddr , info )
@@ -47,7 +45,7 @@ func TestReadServerVersion(t *testing.T) {
4745
4846// Test that the backend status is correct when the backend starts or shuts down.
4947func TestHealthCheck (t * testing.T ) {
50- lg , _ := logger .CreateLoggerForTest (t )
48+ lg , text := logger .CreateLoggerForTest (t )
5149 cfg := newHealthCheckConfigForTest ()
5250 hc := NewDefaultHealthCheck (nil , cfg , lg )
5351 backend , info := newBackendServer (t )
@@ -65,6 +63,7 @@ func TestHealthCheck(t *testing.T) {
6563 backend .setHTTPResp (false )
6664 health = hc .Check (context .Background (), backend .sqlAddr , info )
6765 require .False (t , health .Healthy )
66+ require .NotContains (t , text .String (), "unmarshal body" )
6867 backend .setHTTPResp (true )
6968 health = hc .Check (context .Background (), backend .sqlAddr , info )
7069 require .True (t , health .Healthy )
@@ -113,6 +112,7 @@ func (srv *backendServer) setServerVersion(version string) {
113112 body , _ := json .Marshal (resp )
114113 srv .mockHttpHandler .setHTTPRespBody (string (body ))
115114}
115+
116116func (srv * backendServer ) startHTTPServer () {
117117 if srv .mockHttpHandler == nil {
118118 srv .mockHttpHandler = & mockHttpHandler {
0 commit comments