-
Notifications
You must be signed in to change notification settings - Fork 2
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
7 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
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
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
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 PolarWeb.Publish.Testing.CheckController do | ||
use PolarWeb, :controller | ||
|
||
alias Polar.Machines | ||
|
||
def index(conn, _params) do | ||
checks = Machines.list_checks() | ||
|
||
render(conn, :index, %{checks: checks}) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule PolarWeb.Publish.Testing.CheckJSON do | ||
alias Polar.Machines.Check | ||
|
||
def index(%{checks: checks}) do | ||
%{data: Enum.map(checks, &data/1)} | ||
end | ||
|
||
def data(%Check{} = check) do | ||
%{id: check.id, slug: check.slug} | ||
end | ||
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
2 changes: 1 addition & 1 deletion
2
...publish/version/event_controller_test.exs → ...rollers/publish/event_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
42 changes: 42 additions & 0 deletions
42
test/polar_web/controllers/publish/testing/check_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,42 @@ | ||
defmodule PolarWeb.Publish.Testing.CheckControllerTest do | ||
use PolarWeb.ConnCase | ||
|
||
alias Polar.Accounts | ||
alias Polar.Machines | ||
|
||
import Polar.AccountsFixtures | ||
|
||
setup do | ||
password = Accounts.generate_automation_password() | ||
|
||
bot = bot_fixture(%{password: password}) | ||
|
||
user = Accounts.get_user_by_email_and_password(bot.email, password) | ||
|
||
session_token = | ||
Accounts.generate_user_session_token(user) | ||
|> Base.encode64() | ||
|
||
conn = | ||
build_conn() | ||
|> put_req_header("authorization", session_token) | ||
|
||
{:ok, _check} = | ||
Machines.create_check(%{ | ||
name: "ipv4-issuing", | ||
description: "checks that ipv4 is correctly issued" | ||
}) | ||
|
||
{:ok, conn: conn} | ||
end | ||
|
||
describe "GET /publish/testing/checks" do | ||
test "get list of available checks", %{conn: conn} do | ||
conn = get(conn, "/publish/testing/checks") | ||
|
||
assert %{"data" => data} = json_response(conn, 200) | ||
|
||
assert Enum.count(data) == 1 | ||
end | ||
end | ||
end |