Skip to content

Commit

Permalink
Add test for create event for assessment
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Jun 24, 2024
1 parent df74f09 commit fad50e1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/polar_web/controllers/publish/event_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule PolarWeb.Publish.EventControllerTest do

alias Polar.Accounts
alias Polar.Streams
alias Polar.Machines

setup do
password = Accounts.generate_automation_password()
Expand Down Expand Up @@ -47,4 +48,40 @@ defmodule PolarWeb.Publish.EventControllerTest do
assert %{"id" => _id, "name" => "test"} = data
end
end

describe "POST /publish/testing/assessments/:assessment_id/events" do
setup %{version: version} do
{:ok, check} =
Machines.create_check(%{
name: "ipv4-issuing",
description: "issue ipv4 correctly"
})

{:ok, cluster} =
Machines.create_cluster(%{
name: "example",
type: "lxd",
arch: "amd64",
credential_endpoint: "some.cluster.com:8443",
credential_password: "sometoken",
credential_password_confirmation: "sometoken"
})

{:ok, assessment} =
Machines.create_assessment(version, %{check_id: check.id, cluster_id: cluster.id})

{:ok, assessment: assessment}
end

test "can transition assessment to running", %{conn: conn, assessment: assessment} do
conn =
post(conn, ~p"/publish/testing/assessments/#{assessment.id}/events", %{
"event" => %{"name" => "run"}
})

assert %{"data" => data} = json_response(conn, 201)

assert %{"id" => _id, "name" => _name} = data
end
end
end

0 comments on commit fad50e1

Please sign in to comment.