defmodule VigilWeb.HeartbeatTest do
use VigilWeb.ConnCase, async: true
import Vigil.AccountsFixtures
import Vigil.OrganizationsFixtures
test "a heartbeat POST (or GET) marks the monitor up; a wrong token is a 404", %{conn: conn} do
owner = user_fixture()
org = organization_fixture(owner)
scope = org_scope(owner, org)
project = project_fixture(scope)
{:ok, m} =
Vigil.Uptime.create_monitor(scope, project, %{"name" => "Backup", "type" => "heartbeat"})
path = "/api/0/organizations/#{org.slug}/heartbeat_check/#{m.heartbeat_token}/"
assert %{"isUp" => true} = conn |> post(path) |> json_response(200)
assert %{"isUp" => true} = build_conn() |> get(path) |> json_response(200)
assert Vigil.Repo.get!(Vigil.Uptime.Monitor, m.id).is_up
assert build_conn()
|> post("/api/0/organizations/#{org.slug}/heartbeat_check/#{Ecto.UUID.generate()}/")
|> json_response(404)
end
end
neiam
/vigil
public · Issues · Pulls · Labels · Forks · Compare · Actions queued · Badges · Packages
⭐
Log in to mark this repository.
951 B · text
History
e47e04f