Skip to content

Commit

Permalink
feat: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
panteparak committed Oct 21, 2024
1 parent 2b1a92b commit 54a588d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion health_check/contrib/db_heartbeat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import django

if django.VERSION < (3, 2):
default_app_config = "health_check.contrib.db_heartbeat.apps.HealthCheckConfig"
default_app_config = "health_check.contrib.db_heartbeat.apps.HealthCheckConfig"
3 changes: 2 additions & 1 deletion health_check/contrib/db_heartbeat/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@


class HealthCheckConfig(AppConfig):
name = 'health_check.contrib.db_heartbeat'
name = "health_check.contrib.db_heartbeat"

def ready(self):
from .backends import DatabaseHeartBeatCheck

plugin_dir.register(DatabaseHeartBeatCheck)
4 changes: 3 additions & 1 deletion health_check/contrib/db_heartbeat/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def check_status(self):
result = cursor.fetchone()

if result != (1,):
raise ServiceReturnedUnexpectedResult("Health Check query did not return the expected result.")
raise ServiceReturnedUnexpectedResult(
"Health Check query did not return the expected result."
)
except Exception as e:
raise ServiceUnavailable(f"Database health check failed: {e}")

0 comments on commit 54a588d

Please sign in to comment.