total rebase
[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     keys = Map.keys(result)
13
14     assert Keyword.equal?(keys, [
15              :active,
16              :healthy,
17              :idle,
18              :job_queue_stats,
19              :memory_used,
20              :pool_size
21            ])
22   end
23
24   describe "check_health/1" do
25     test "pool size equals active connections" do
26       result = Healthcheck.check_health(%Healthcheck{pool_size: 10, active: 10})
27       refute result.healthy
28     end
29
30     test "check_health/1" do
31       result = Healthcheck.check_health(%Healthcheck{pool_size: 10, active: 9})
32       assert result.healthy
33     end
34   end
35 end