First
[anni] / test / pleroma / healthcheck_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.HealthcheckTest do
6   use Pleroma.DataCase, async: true
7   alias Pleroma.Healthcheck
8
9   test "system_info/0" do
10     result = Healthcheck.system_info() |> Map.from_struct()
11
12     assert Map.keys(result) == [
13              :active,
14              :healthy,
15              :idle,
16              :job_queue_stats,
17              :memory_used,
18              :pool_size
19            ]
20   end
21
22   describe "check_health/1" do
23     test "pool size equals active connections" do
24       result = Healthcheck.check_health(%Healthcheck{pool_size: 10, active: 10})
25       refute result.healthy
26     end
27
28     test "chech_health/1" do
29       result = Healthcheck.check_health(%Healthcheck{pool_size: 10, active: 9})
30       assert result.healthy
31     end
32   end
33 end