diff options
author | lain <lain@soykaf.club> | 2024-05-27 09:46:57 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2024-05-27 09:46:57 +0000 |
commit | 5e4306012862417a05127aa89080857eed8461b8 (patch) | |
tree | bb2e55ed5448ceff9aa2a17042a4350daee07de9 /test | |
parent | c3c804b71ffb5c4d2f1a0595b4444efb44ca8180 (diff) | |
parent | d35b69d2686e62cc5076bd7a33449f98f8a11a85 (diff) | |
download | pleroma-5e4306012862417a05127aa89080857eed8461b8.tar.gz pleroma-5e4306012862417a05127aa89080857eed8461b8.zip |
Merge branch 'search-healthcheck' into 'develop'
Search backend healthcheck process
See merge request pleroma/pleroma!4120
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/search/healthcheck_test.exs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/pleroma/search/healthcheck_test.exs b/test/pleroma/search/healthcheck_test.exs new file mode 100644 index 000000000..e7649d949 --- /dev/null +++ b/test/pleroma/search/healthcheck_test.exs @@ -0,0 +1,49 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2024 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Search.HealthcheckTest do + use Pleroma.DataCase + + import Tesla.Mock + + alias Pleroma.Search.Healthcheck + + @good1 "http://good1.example.com/healthz" + @good2 "http://good2.example.com/health" + @bad "http://bad.example.com/healthy" + + setup do + mock(fn + %{method: :get, url: @good1} -> + %Tesla.Env{ + status: 200, + body: "" + } + + %{method: :get, url: @good2} -> + %Tesla.Env{ + status: 200, + body: "" + } + + %{method: :get, url: @bad} -> + %Tesla.Env{ + status: 503, + body: "" + } + end) + + :ok + end + + test "true for 200 responses" do + assert Healthcheck.check([@good1]) + assert Healthcheck.check([@good1, @good2]) + end + + test "false if any response is not a 200" do + refute Healthcheck.check([@bad]) + refute Healthcheck.check([@good1, @bad]) + end +end |