@@ -136,6 +136,16 @@ def test_lbheartbeat(dockerflow, test_client):
136136 assert response .body == b""
137137
138138
139+ def test_error_returns_500_and_logs_error (dockerflow , test_client , caplog ):
140+ with caplog .at_level (logging .INFO , logger = "dockerflow.sanic" ):
141+ _ , response = test_client .get ("/__error__" )
142+ assert response .status_code == 500
143+ assert len (caplog .records ) >= 1
144+ record = caplog .records [0 ]
145+ assert record .getMessage () == "The __error__ endpoint was called"
146+ assert record .levelno == logging .ERROR
147+
148+
139149def test_heartbeat (dockerflow , test_client ):
140150 _ , response = test_client .get ("/__heartbeat__" )
141151 assert response .status == 200
@@ -214,7 +224,7 @@ def test_redis_check(dockerflow_redis, mocker, test_client):
214224 [
215225 (
216226 "connection" ,
217- {health .ERROR_CANNOT_CONNECT_REDIS : "Could not connect to " " redis: fake" },
227+ {health .ERROR_CANNOT_CONNECT_REDIS : "Could not connect to redis: fake" },
218228 ),
219229 ("redis" , {health .ERROR_REDIS_EXCEPTION : 'Redis error: "fake"' }),
220230 ("malformed" , {health .ERROR_REDIS_PING_FAILED : "Redis ping failed" }),
0 commit comments