-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
apps/backend_fight_web/lib/backend_fight_web/controllers/healthcheck_controller.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
defmodule BackendFightWeb.HealthcheckController do | ||
use BackendFightWeb, :controller | ||
|
||
alias DB.Repo | ||
alias Ecto.Adapters.SQL | ||
|
||
def index(conn, _params) do | ||
{:ok, _result} = check_database() | ||
|
||
conn |> send_resp(200, "") | ||
end | ||
|
||
defp check_database, do: SQL.query(Repo, "select 1", []) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
apps/backend_fight_web/test/backend_fight_web/controllers/healthcheck_controller_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule BackendFightWeb.HealthcheckControllerTest do | ||
use BackendFightWeb.ConnCase | ||
|
||
test "GET /healthcheck, when everything happens as it should, it is expected to return 200 without a body", %{ | ||
conn: conn | ||
} do | ||
conn = conn |> get("/healthcheck") | ||
|
||
assert "" = response(conn, 200) | ||
end | ||
end |