aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/healthcheck_test.exs22
-rw-r--r--test/web/twitter_api/util_controller_test.exs6
2 files changed, 28 insertions, 0 deletions
diff --git a/test/healthcheck_test.exs b/test/healthcheck_test.exs
new file mode 100644
index 000000000..e05061220
--- /dev/null
+++ b/test/healthcheck_test.exs
@@ -0,0 +1,22 @@
+defmodule Pleroma.HealthcheckTest do
+ use Pleroma.DataCase
+ alias Pleroma.Healthcheck
+
+ test "system_info/0" do
+ result = Healthcheck.system_info() |> Map.from_struct()
+
+ assert Map.keys(result) == [:active, :healthy, :idle, :memory_used, :pool_size]
+ end
+
+ describe "check_health/1" do
+ test "pool size equals active connections" do
+ result = Healthcheck.check_health(%Healthcheck{pool_size: 10, active: 10})
+ refute result.healthy
+ end
+
+ test "chech_health/1" do
+ result = Healthcheck.check_health(%Healthcheck{pool_size: 10, active: 9})
+ assert result.healthy
+ end
+ end
+end
diff --git a/test/web/twitter_api/util_controller_test.exs b/test/web/twitter_api/util_controller_test.exs
index c58b49ea4..56474447b 100644
--- a/test/web/twitter_api/util_controller_test.exs
+++ b/test/web/twitter_api/util_controller_test.exs
@@ -245,4 +245,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
assert html_response(response, 200) =~ "Log in to follow"
end
end
+
+ test "GET /api/pleroma/healthcheck", %{conn: conn} do
+ conn = get(conn, "/api/pleroma/healthcheck")
+
+ assert conn.status in [200, 503]
+ end
end